Skip to content

Test failures with pytest 8.0.2 #71

@mweinelt

Description

@mweinelt

Hi!

After updating pytest to 8.x we are seeing test failures with pytest-snapshot 0.9.0 over in nixpkgs.

============================= test session starts ==============================
platform linux -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0
rootdir: /build/source
plugins: snapshot-0.9.0
collected 108 items                                                            

tests/test_assert_match.py ....F.............................x....       [ 36%]
tests/test_assert_match_dir.py ............................              [ 62%]
tests/test_misc.py .........................................             [100%]

=================================== FAILURES ===================================
_______________________ test_assert_match_failure_bytes ________________________

request = <FixtureRequest for <Function test_assert_match_failure_bytes>>
testdir = <Testdir local('/build/pytest-of-nixbld/pytest-0/test_assert_match_failure_bytes0')>
basic_case_dir = local('/build/pytest-of-nixbld/pytest-0/test_assert_match_failure_bytes0/case_dir')

    def test_assert_match_failure_bytes(request, testdir, basic_case_dir):
        testdir.makepyfile(r"""
            import os
            def test_sth(snapshot):
                snapshot.snapshot_dir = 'case_dir'
                snapshot.assert_match(b'the INCORRECT value of snapshot1.txt' + os.linesep.encode(), 'snapshot1.txt')
        """)
        result = runpytest_with_assert_mode(testdir, request, '-v', '--assert=rewrite')
>       result.stdout.fnmatch_lines([
            r'*::test_sth FAILED*',
            r">* snapshot.assert_match(b'the INCORRECT value of snapshot1.txt' + os.linesep.encode(), 'snapshot1.txt')",
            r'E* AssertionError: value does not match the expected value in snapshot case_dir?snapshot1.txt',
            r'E*   (run pytest with --snapshot-update to update snapshots)',
            r"E* assert * == *",
            r"E* At index 4 diff: * != *",
            r"E* Full diff:",
            r"E* - b'the valu\xc3\x89 of snapshot1.txt{}'".format(repr(os.linesep)[1:-1]),
            r"E* + b'the INCORRECT value of snapshot1.txt{}'".format(repr(os.linesep)[1:-1]),
        ])
E       Failed: nomatch: '*::test_sth FAILED*'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0 -- /nix/store/vhlk4r8ralh744khcy3vy47ijw5rvpw5-python3-3.1
E           and: 'cachedir: .pytest_cache'
E           and: 'rootdir: /build/pytest-of-nixbld/pytest-0/test_assert_match_failure_bytes0'
E           and: 'plugins: snapshot-0.9.0'
E           and: 'collecting ... collected 1 item'
E           and: ''
E       fnmatch: '*::test_sth FAILED*'
E          with: 'test_assert_match_failure_bytes.py::test_sth FAILED                      [100%]'
E       nomatch: ">* snapshot.assert_match(b'the INCORRECT value of snapshot1.txt' + os.linesep.encode(), 'snapshot1.txt')"
E           and: ''
E           and: '=================================== FAILURES ==================================='
E           and: '___________________________________ test_sth ___________________________________'
E           and: ''
E           and: 'snapshot = <pytest_snapshot.plugin.Snapshot object at 0x7ffff5e1c2d0>'
E           and: ''
E           and: '    def test_sth(snapshot):'
E           and: "        snapshot.snapshot_dir = 'case_dir'"
E       fnmatch: ">* snapshot.assert_match(b'the INCORRECT value of snapshot1.txt' + os.linesep.encode(), 'snapshot1.txt')"
E          with: ">       snapshot.assert_match(b'the INCORRECT value of snapshot1.txt' + os.linesep.encode(), 'snapshot1.txt')"
E       fnmatch: 'E* AssertionError: value does not match the expected value in snapshot case_dir?snapshot1.txt'
E          with: 'E       AssertionError: value does not match the expected value in snapshot case_dir/snapshot1.txt'
E       fnmatch: 'E*   (run pytest with --snapshot-update to update snapshots)'
E          with: 'E         (run pytest with --snapshot-update to update snapshots)'
E       fnmatch: 'E* assert * == *'
E          with: "E       assert b'the INCORRE...apshot1.txt\\n' == b'the valu\\xc...apshot1.txt\\n'"
E       nomatch: 'E* At index 4 diff: * != *'
E           and: 'E         '
E       fnmatch: 'E* At index 4 diff: * != *'
E          with: "E         At index 4 diff: b'I' != b'v'"
E       nomatch: 'E* Full diff:'
E           and: 'E         '
E       fnmatch: 'E* Full diff:'
E          with: 'E         Full diff:'
E       nomatch: "E* - b'the valu\\xc3\\x89 of snapshot1.txt\\n'"
E           and: "E         - (b'the valu\\xc3\\x89 of snapshot1.txt\\n')"
E           and: 'E         ?            ^^^^^^^^'
E           and: "E         + (b'the INCORRECT value of snapshot1.txt\\n')"
E           and: 'E         ?        ++++++++++    ^'
E           and: ''
E           and: 'test_assert_match_failure_bytes.py:4: AssertionError'
E           and: '=========================== short test summary info ============================'
E           and: 'FAILED test_assert_match_failure_bytes.py::test_sth - AssertionError: value d...'
E           and: '============================== 1 failed in 0.01s ==============================='
E       remains unmatched: "E* - b'the valu\\xc3\\x89 of snapshot1.txt\\n'"

/build/source/tests/test_assert_match.py:82: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0 -- /nix/store/vhlk4r8ralh744khcy3vy47ijw5rvpw5-python3-3.11.8/bin/python3.11
cachedir: .pytest_cache
rootdir: /build/pytest-of-nixbld/pytest-0/test_assert_match_failure_bytes0
plugins: snapshot-0.9.0
collecting ... collected 1 item

test_assert_match_failure_bytes.py::test_sth FAILED                      [100%]

=================================== FAILURES ===================================
___________________________________ test_sth ___________________________________

snapshot = <pytest_snapshot.plugin.Snapshot object at 0x7ffff5e1c2d0>

    def test_sth(snapshot):
        snapshot.snapshot_dir = 'case_dir'
>       snapshot.assert_match(b'the INCORRECT value of snapshot1.txt' + os.linesep.encode(), 'snapshot1.txt')
E       AssertionError: value does not match the expected value in snapshot case_dir/snapshot1.txt
E         (run pytest with --snapshot-update to update snapshots)
E       assert b'the INCORRE...apshot1.txt\n' == b'the valu\xc...apshot1.txt\n'
E         
E         At index 4 diff: b'I' != b'v'
E         
E         Full diff:
E         - (b'the valu\xc3\x89 of snapshot1.txt\n')
E         ?            ^^^^^^^^
E         + (b'the INCORRECT value of snapshot1.txt\n')
E         ?        ++++++++++    ^

test_assert_match_failure_bytes.py:4: AssertionError
=========================== short test summary info ============================
FAILED test_assert_match_failure_bytes.py::test_sth - AssertionError: value d...
============================== 1 failed in 0.01s ===============================
=========================== short test summary info ============================
FAILED tests/test_assert_match.py::test_assert_match_failure_bytes - Failed: nomatch: '*::test_sth FAILED*'
=================== 1 failed, 106 passed, 1 xfailed in 4.55s ===================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions