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

Method test_close

Lib/test/test_lzma.py:704–722  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

702 preset=6, filters=FILTERS_RAW_1)
703
704 def test_close(self):
705 with BytesIO(COMPRESSED_XZ) as src:
706 f = LZMAFile(src)
707 f.close()
708 # LZMAFile.close() should not close the underlying file object.
709 self.assertFalse(src.closed)
710 # Try closing an already-closed LZMAFile.
711 f.close()
712 self.assertFalse(src.closed)
713
714 # Test with a real file on disk, opened directly by LZMAFile.
715 with TempFile(TESTFN, COMPRESSED_XZ):
716 f = LZMAFile(TESTFN)
717 fp = f._fp
718 f.close()
719 # Here, LZMAFile.close() *should* close the underlying file object.
720 self.assertTrue(fp.closed)
721 # Try closing an already-closed LZMAFile.
722 f.close()
723
724 def test_closed(self):
725 f = LZMAFile(BytesIO(COMPRESSED_XZ))

Callers

nothing calls this directly

Calls 6

closeMethod · 0.95
BytesIOClass · 0.90
LZMAFileClass · 0.90
assertFalseMethod · 0.80
assertTrueMethod · 0.80
TempFileClass · 0.70

Tested by

no test coverage detected