From: sobolevn Date: Fri, 14 Mar 2025 11:54:37 +0000 (+0300) Subject: [3.12] gh-131219: Improve tests in `test_lzma.py` by adding more asserts (GH-131220... X-Git-Tag: v3.12.10~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6658ada1ea2d32d19038924f8f88868ecf18d161;p=thirdparty%2FPython%2Fcpython.git [3.12] gh-131219: Improve tests in `test_lzma.py` by adding more asserts (GH-131220) (#131237) Co-authored-by: sobolevn --- diff --git a/Lib/test/test_lzma.py b/Lib/test/test_lzma.py index db290e139327..14029c17539b 100644 --- a/Lib/test/test_lzma.py +++ b/Lib/test/test_lzma.py @@ -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)