MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_del_on_close

Method test_del_on_close

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

Source from the content-addressed store, hash-verified

1214 )
1215
1216 def test_del_on_close(self):
1217 # A SpooledTemporaryFile is deleted when closed
1218 dir = tempfile.mkdtemp()
1219 try:
1220 f = tempfile.SpooledTemporaryFile(max_size=10, dir=dir)
1221 self.assertFalse(f._rolled)
1222 f.write(b'blat ' * 5)
1223 self.assertTrue(f._rolled)
1224 filename = f.name
1225 f.close()
1226 self.assertEqual(os.listdir(dir), [])
1227 if not isinstance(filename, int):
1228 self.assertFalse(os.path.exists(filename),
1229 "SpooledTemporaryFile %s exists after close" % filename)
1230 finally:
1231 os.rmdir(dir)
1232
1233 def test_del_unrolled_file(self):
1234 # The unrolled SpooledTemporaryFile should raise a ResourceWarning

Callers

nothing calls this directly

Calls 10

writeMethod · 0.95
closeMethod · 0.95
isinstanceFunction · 0.85
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