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

Method test_close

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

Source from the content-addressed store, hash-verified

692 preset=6, filters=FILTERS_RAW_1)
693
694 def test_close(self):
695 with BytesIO(COMPRESSED_XZ) as src:
696 f = LZMAFile(src)
697 f.close()
698 # LZMAFile.close() should not close the underlying file object.
699 self.assertFalse(src.closed)
700 # Try closing an already-closed LZMAFile.
701 f.close()
702 self.assertFalse(src.closed)
703
704 # Test with a real file on disk, opened directly by LZMAFile.
705 with TempFile(TESTFN, COMPRESSED_XZ):
706 f = LZMAFile(TESTFN)
707 fp = f._fp
708 f.close()
709 # Here, LZMAFile.close() *should* close the underlying file object.
710 self.assertTrue(fp.closed)
711 # Try closing an already-closed LZMAFile.
712 f.close()
713
714 def test_closed(self):
715 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