Skip to content

FileTestCase in test_lzma can be improved #131219

Closed
@sobolevn

Description

@sobolevn

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

Activity

added a commit that references this issue on Mar 14, 2025

pythongh-131219: Improve tests in `test_lzma.py` by adding more asserts

f9c32df
added
type-bugAn unexpected behavior, bug, or error
testsTests in the Lib/test dir
on Mar 14, 2025
self-assigned this
on Mar 14, 2025
added a commit that references this issue on Mar 14, 2025

gh-131219: Improve tests in `test_lzma.py` by adding more asserts (#1…

f6c24a5
added a commit that references this issue on Mar 14, 2025

pythongh-131219: Improve tests in `test_lzma.py` by adding more asser…

added 2 commits that reference this issue on Mar 14, 2025

[3.13] gh-131219: Improve tests in `test_lzma.py` by adding more asse…

7d498aa

[3.12] pythongh-131219: Improve tests in `test_lzma.py` by adding mor…

29db7f0
added a commit that references this issue on Mar 14, 2025

[3.12] gh-131219: Improve tests in `test_lzma.py` by adding more asse…

6658ada
added a commit that references this issue on Mar 14, 2025

[3.12] pythongh-131219: Improve tests in `test_lzma.py` by adding mor…

added a commit that references this issue on Mar 17, 2025

pythongh-131219: Improve tests in `test_lzma.py` by adding more asser…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    `FileTestCase` in `test_lzma` can be improved · Issue #131219 · python/cpython