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

Method test_del_on_close

Lib/test/test_tempfile.py:1235–1250  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1233 )
1234
1235 def test_del_on_close(self):
1236 # A SpooledTemporaryFile is deleted when closed
1237 dir = tempfile.mkdtemp()
1238 try:
1239 f = tempfile.SpooledTemporaryFile(max_size=10, dir=dir)
1240 self.assertFalse(f._rolled)
1241 f.write(b'blat ' * 5)
1242 self.assertTrue(f._rolled)
1243 filename = f.name
1244 f.close()
1245 self.assertEqual(os.listdir(dir), [])
1246 if not isinstance(filename, int):
1247 self.assertFalse(os.path.exists(filename),
1248 "SpooledTemporaryFile %s exists after close" % filename)
1249 finally:
1250 os.rmdir(dir)
1251
1252 def test_del_unrolled_file(self):
1253 # The unrolled SpooledTemporaryFile should raise a ResourceWarning

Callers

nothing calls this directly

Calls 9

writeMethod · 0.95
closeMethod · 0.95
mkdtempMethod · 0.80
assertFalseMethod · 0.80
assertTrueMethod · 0.80
listdirMethod · 0.80
rmdirMethod · 0.80
assertEqualMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected