From 6658ada1ea2d32d19038924f8f88868ecf18d161 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 14 Mar 2025 14:54:37 +0300 Subject: [PATCH] [3.12] gh-131219: Improve tests in `test_lzma.py` by adding more asserts (GH-131220) (#131237) Co-authored-by: sobolevn --- Lib/test/test_lzma.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) 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) -- 2.47.3