Skip to content

Commit 6658ada

Browse files
authored
[3.12] gh-131219: Improve tests in test_lzma.py by adding more asserts (GH-131220) (#131237)
Co-authored-by: sobolevn <[email protected]>
1 parent 77ece5a commit 6658ada

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Lib/test/test_lzma.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -538,13 +538,13 @@ class FileTestCase(unittest.TestCase):
538538

539539
def test_init(self):
540540
with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
541-
pass
541+
self.assertIsInstance(f, LZMAFile)
542542
with LZMAFile(BytesIO(), "w") as f:
543-
pass
543+
self.assertIsInstance(f, LZMAFile)
544544
with LZMAFile(BytesIO(), "x") as f:
545-
pass
545+
self.assertIsInstance(f, LZMAFile)
546546
with LZMAFile(BytesIO(), "a") as f:
547-
pass
547+
self.assertIsInstance(f, LZMAFile)
548548

549549
def test_init_with_PathLike_filename(self):
550550
filename = FakePath(TESTFN)
@@ -567,25 +567,25 @@ def test_init_with_filename(self):
567567

568568
def test_init_mode(self):
569569
with TempFile(TESTFN):
570-
with LZMAFile(TESTFN, "r"):
571-
pass
572-
with LZMAFile(TESTFN, "rb"):
573-
pass
574-
with LZMAFile(TESTFN, "w"):
575-
pass
576-
with LZMAFile(TESTFN, "wb"):
577-
pass
578-
with LZMAFile(TESTFN, "a"):
579-
pass
580-
with LZMAFile(TESTFN, "ab"):
581-
pass
570+
with LZMAFile(TESTFN, "r") as f:
571+
self.assertIsInstance(f, LZMAFile)
572+
with LZMAFile(TESTFN, "rb") as f:
573+
self.assertIsInstance(f, LZMAFile)
574+
with LZMAFile(TESTFN, "w") as f:
575+
self.assertIsInstance(f, LZMAFile)
576+
with LZMAFile(TESTFN, "wb") as f:
577+
self.assertIsInstance(f, LZMAFile)
578+
with LZMAFile(TESTFN, "a") as f:
579+
self.assertIsInstance(f, LZMAFile)
580+
with LZMAFile(TESTFN, "ab") as f:
581+
self.assertIsInstance(f, LZMAFile)
582582

583583
def test_init_with_x_mode(self):
584584
self.addCleanup(unlink, TESTFN)
585585
for mode in ("x", "xb"):
586586
unlink(TESTFN)
587587
with LZMAFile(TESTFN, mode) as f:
588-
pass
588+
self.assertIsInstance(f, LZMAFile)
589589
with self.assertRaises(FileExistsError):
590590
LZMAFile(TESTFN, mode)
591591

0 commit comments

Comments
 (0)