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

Method test_close

Lib/test/test_zstd.py:1713–1735  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1711 os.remove(filename)
1712
1713 def test_close(self):
1714 with io.BytesIO(COMPRESSED_100_PLUS_32KB) as src:
1715 f = ZstdFile(src)
1716 f.close()
1717 # ZstdFile.close() should not close the underlying file object.
1718 self.assertFalse(src.closed)
1719 # Try closing an already-closed ZstdFile.
1720 f.close()
1721 self.assertFalse(src.closed)
1722
1723 # Test with a real file on disk, opened directly by ZstdFile.
1724 with tempfile.NamedTemporaryFile(delete=False) as tmp_f:
1725 filename = pathlib.Path(tmp_f.name)
1726
1727 f = ZstdFile(filename)
1728 fp = f._fp
1729 f.close()
1730 # Here, ZstdFile.close() *should* close the underlying file object.
1731 self.assertTrue(fp.closed)
1732 # Try closing an already-closed ZstdFile.
1733 f.close()
1734
1735 os.remove(filename)
1736
1737 def test_closed(self):
1738 f = ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB))

Callers

nothing calls this directly

Calls 5

closeMethod · 0.95
ZstdFileClass · 0.90
assertFalseMethod · 0.80
assertTrueMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected