Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[3.12] gh-131219: Improve tests in test_lzma.py by adding more asserts (GH-131220) #131237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Lib/test/test_lzma.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -567,25 +567,25 @@ def test_init_with_filename(self):

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)

Expand Down
Loading