Skip to content

"ERROR at" test case name headings ambiguous if they use the same test case function name #14902

Description

@cswrd

First of all, thanks for providing and maintaining pytest!

Given a minimal setup like this:

# conftest.py
import pytest

@pytest.fixture
def fixture():
    raise Exception()
# test_1.py and test_2.py
def test(fixture):
    pass

The "ERROR at" section being printed is ambiguous. You can't tell which section is referring to which test case. Both say ERROR at setup of test.

================================ ERRORS =================================
________________________ ERROR at setup of test _________________________

    @pytest.fixture
    def fixture():
>       raise Exception()
E       Exception

conftest.py:5: Exception
________________________ ERROR at setup of test _________________________

    @pytest.fixture
    def fixture():
>       raise Exception()
E       Exception

conftest.py:5: Exception

Given the short test summary section, sometimes it's possible to "reverse engineer" which section is referring to which test case especially if they were caused by different exception types and/or lines of code causing the issue. It requires scrolling back and forth, tough.

The "FAILURES" section uses the same headings. At least there's 1 line of code within the stack trace revealing the originally affected test case usually, though.

Afaik there is neither a necessity nor a recommendation to make test case function names unique. So I wonder, why it's not printing its full name by default for these sections.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions