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

Method test_close

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

Source from the content-addressed store, hash-verified

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