]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-131219: Improve tests in `test_lzma.py` by adding more asserts (GH-131220...
authorsobolevn <mail@sobolevn.me>
Fri, 14 Mar 2025 11:54:37 +0000 (14:54 +0300)
committerGitHub <noreply@github.com>
Fri, 14 Mar 2025 11:54:37 +0000 (11:54 +0000)
Co-authored-by: sobolevn <mail@sobolevn.me>
Lib/test/test_lzma.py

index db290e139327e025f9073c16b75fef940aec4981..14029c17539b855b9ef1dff6ac0c52e153fbd85c 100644 (file)
@@ -538,13 +538,13 @@ class FileTestCase(unittest.TestCase):
 
     def test_init(self):
         with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
-            pass
+            self.assertIsInstance(f, LZMAFile)
         with LZMAFile(BytesIO(), "w") as f:
-            pass
+            self.assertIsInstance(f, LZMAFile)
         with LZMAFile(BytesIO(), "x") as f:
-            pass
+            self.assertIsInstance(f, LZMAFile)
         with LZMAFile(BytesIO(), "a") as f:
-            pass
+            self.assertIsInstance(f, LZMAFile)
 
     def test_init_with_PathLike_filename(self):
         filename = FakePath(TESTFN)
@@ -567,25 +567,25 @@ class FileTestCase(unittest.TestCase):
 
     def test_init_mode(self):
         with TempFile(TESTFN):
-            with LZMAFile(TESTFN, "r"):
-                pass
-            with LZMAFile(TESTFN, "rb"):
-                pass
-            with LZMAFile(TESTFN, "w"):
-                pass
-            with LZMAFile(TESTFN, "wb"):
-                pass
-            with LZMAFile(TESTFN, "a"):
-                pass
-            with LZMAFile(TESTFN, "ab"):
-                pass
+            with LZMAFile(TESTFN, "r") as f:
+                self.assertIsInstance(f, LZMAFile)
+            with LZMAFile(TESTFN, "rb") as f:
+                self.assertIsInstance(f, LZMAFile)
+            with LZMAFile(TESTFN, "w") as f:
+                self.assertIsInstance(f, LZMAFile)
+            with LZMAFile(TESTFN, "wb") as f:
+                self.assertIsInstance(f, LZMAFile)
+            with LZMAFile(TESTFN, "a") as f:
+                self.assertIsInstance(f, LZMAFile)
+            with LZMAFile(TESTFN, "ab") as f:
+                self.assertIsInstance(f, LZMAFile)
 
     def test_init_with_x_mode(self):
         self.addCleanup(unlink, TESTFN)
         for mode in ("x", "xb"):
             unlink(TESTFN)
             with LZMAFile(TESTFN, mode) as f:
-                pass
+                self.assertIsInstance(f, LZMAFile)
             with self.assertRaises(FileExistsError):
                 LZMAFile(TESTFN, mode)