Skip to content

FileTestCase in test_lzma can be improved #131219

Closed

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

  1. added a commit that references this issue on Mar 14, 2025
  2. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    on Mar 14, 2025
  3. self-assigned this
    on Mar 14, 2025
  4. added a commit that references this issue on Mar 14, 2025
  5. added a commit that references this issue on Mar 14, 2025
  6. added 2 commits that reference this issue on Mar 14, 2025
  7. added a commit that references this issue on Mar 14, 2025
  8. added a commit that references this issue on Mar 14, 2025
  9. added a commit that references this issue on Mar 17, 2025
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