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

Method test_del_on_close

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

Source from the content-addressed store, hash-verified

1016 "NamedTemporaryFile %s does not exist" % f.name)
1017
1018 def test_del_on_close(self):
1019 # A NamedTemporaryFile is deleted when closed
1020 dir = tempfile.mkdtemp()
1021 try:
1022 with tempfile.NamedTemporaryFile(dir=dir) as f:
1023 f.write(b'blat')
1024 self.assertEqual(os.listdir(dir), [])
1025 self.assertFalse(os.path.exists(f.name),
1026 "NamedTemporaryFile %s exists after close" % f.name)
1027 finally:
1028 os.rmdir(dir)
1029
1030 def test_dis_del_on_close(self):
1031 # Tests that delete-on-close can be disabled

Callers

nothing calls this directly

Calls 7

mkdtempMethod · 0.80
listdirMethod · 0.80
assertFalseMethod · 0.80
rmdirMethod · 0.80
writeMethod · 0.45
assertEqualMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected