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

Skip to content

FileTestCase in test_lzma can be improved #131219

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

Closed
sobolevn opened this issue Mar 14, 2025 · 0 comments
Closed

FileTestCase in test_lzma can be improved #131219

sobolevn opened this issue Mar 14, 2025 · 0 comments
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Mar 14, 2025

There are several tests that do not assert anything:

def test_init(self):
with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
pass
with LZMAFile(BytesIO(), "w") as f:
pass
with LZMAFile(BytesIO(), "x") as f:
pass
with LZMAFile(BytesIO(), "a") as f:
pass

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
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

I propose to assert the context manager type and the mode.
I have a PR ready.

Linked PRs

sobolevn added a commit to sobolevn/cpython that referenced this issue Mar 14, 2025
@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir labels Mar 14, 2025
@sobolevn sobolevn self-assigned this Mar 14, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 14, 2025
sobolevn added a commit that referenced this issue Mar 14, 2025
…rts (GH-131220) (#131231)

gh-131219: Improve tests in `test_lzma.py` by adding more asserts (GH-131220)
(cherry picked from commit f6c24a5)

Co-authored-by: sobolevn <[email protected]>
sobolevn added a commit to sobolevn/cpython that referenced this issue Mar 14, 2025
…e asserts (pythonGH-131220)

(cherry picked from commit f6c24a5)

Co-authored-by: sobolevn <[email protected]>
sobolevn added a commit that referenced this issue Mar 14, 2025
mikec9 pushed a commit to mikec9/cpython that referenced this issue Mar 14, 2025
plashchynski pushed a commit to plashchynski/cpython that referenced this issue Mar 17, 2025
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant