Skip to content

fixtures: show test as skip location if skipped from an xunit setup function #11216

@bluetech

Description

@bluetech

PR #10482 made it so that if a fixture calls skip(), the skip location is shown as the test function, not the fixture. But it excluded xunit setup fixtures from this.

I suspect this was done to make a pre-existing test pass, however I think that the same reason for fixtures applies to xunit fixtures just as well, so we shouldn't exclude it.

Would also remove a string-hack that was used to implement this exclusion...

pytest/src/_pytest/fixtures.py

Lines 1162 to 1168 in bf451d4

try:
result = call_fixture_func(fixturefunc, request, kwargs)
except TEST_OUTCOME as e:
if isinstance(e, skip.Exception) and not fixturefunc.__name__.startswith(
"xunit_setup"
):
e._use_item_location = True

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: fixturesanything involving fixtures directly or indirectly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions