MCPcopy Index your code
hub / github.com/python/cpython / test_context_manager_with_filename

Method test_context_manager_with_filename

Lib/test/audiotests.py:115–130  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

113 self.assertEqual(testfile.closed, self.close_fd)
114
115 def test_context_manager_with_filename(self):
116 # If the file doesn't get closed, this test won't fail, but it will
117 # produce a resource leak warning.
118 with self.module.open(TESTFN, 'wb') as f:
119 f.setnchannels(self.nchannels)
120 f.setsampwidth(self.sampwidth)
121 f.setframerate(self.framerate)
122 f.setcomptype(self.comptype, self.compname)
123 with self.module.open(TESTFN) as f:
124 self.assertFalse(f.getfp().closed)
125 params = f.getparams()
126 self.assertEqual(params.nchannels, self.nchannels)
127 self.assertEqual(params.sampwidth, self.sampwidth)
128 self.assertEqual(params.framerate, self.framerate)
129 if not self.close_fd:
130 self.assertIsNone(f.getfp())
131
132 def test_write(self):
133 f = self.create_file(TESTFN)

Callers

nothing calls this directly

Calls 10

setnchannelsMethod · 0.80
setsampwidthMethod · 0.80
setframerateMethod · 0.80
setcomptypeMethod · 0.80
assertFalseMethod · 0.80
getfpMethod · 0.80
assertIsNoneMethod · 0.80
openMethod · 0.45
getparamsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected