Skip to content

Incorrect PASSED tests in extra test summary info #292

@cgoldberg

Description

@cgoldberg

pytest accepts the -r p argument for displaying passed tests in the extra test summary info (shown when tests finish). This acts really weird with pytest-sugar installed.

For example, I have a test file containing the following:

def test_pass():
    assert True

When running this with pytest -r p, I expect to see 1 PASSED test in the test summary. However, I see it 3 times:

$ pytest -r p test_foo.py 
Test session starts (platform: linux, Python 3.13.2, pytest 8.3.5, pytest-sugar 1.0.0)
rootdir: /home/cgoldberg617/code
plugins: sugar-1.0.0
collected 1 item                                                                                                                                                         

 test_foo.py ✓                                                                                                                                             100% ██████████
======================================================================== short test summary info =========================================================================
PASSED test_foo.py::test_pass
PASSED test_foo.py::test_pass
PASSED test_foo.py::test_pass

Results (0.05s):
       1 passed

Here is another example. I have a test file containing the following:

def test_fail():
    assert False

When running this with pytest -r p, I expect to see 0 PASSED tests in the test summary. However, I see it shown 2 times as PASSED:

Test session starts (platform: linux, Python 3.13.2, pytest 8.3.5, pytest-sugar 1.0.0)
rootdir: /home/cgoldberg617/code
plugins: sugar-1.0.0
collected 1 item                                                                                                                                                         


――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― test_fail ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

    def test_fail():
>       assert False
E       assert False

test_foo.py:3: AssertionError

 test_foo.py ⨯                                                                                                                                             100% ██████████
======================================================================== short test summary info =========================================================================
PASSED test_foo.py::test_fail
PASSED test_foo.py::test_fail

Results (0.08s):
       1 failed
         - test_foo.py:2 test_fail

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