GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Double `pytest.skip` leads to failure · Issue #13537 · pytest-dev/pytest

Double pytest.skip leads to failure #13537

New issue
Copy link
New issue
Copy link
Closed
Closed
Double pytest.skip leads to failure#13537
Copy link
Labels
topic: tracebacksrelated to displaying and handling of tracebackstype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

Description

@ego-thales
ego-thales
opened on Jun 18, 2025
Issue body actions

Hello everyone.

I think the following is a bug.

@pytest.fixture
def fixA():
    yield
    pytest.skip(reason="A")

@pytest.fixture
def fixB():
    yield
    pytest.skip(reason="B")

def test_skip(fixA, fixB):  # FAILS
    assert True

Gives the following error report (removed tracebacks).

____________________________ ERROR at teardown of test_skip _____________________________
  + Exception Group Traceback (most recent call last):
  | <traceback>
  | BaseExceptionGroup: errors while tearing down <Function test_skip> (2 sub-exceptions)
  +-+---------------- 1 ----------------
    | <traceback>
    | Skipped: A
    +---------------- 2 ----------------
    | <traceback>
    | Skipped: B
    +------------------------------------

Maybe pytest checks for the error raised being of the type of skips, and thus here it bugs because it's an ExceptionGroup and not a skip type? I'm just very wildly guessing, I don't know the internals of pytest.

Activity

Next
  1. ego-thales
    changed the title [-]Double `pytest.skip` lead to failure[/-] [+]Double `pytest.skip` leads to failure[/+] on Jun 18, 2025
  2. The-Compiler commented on Jun 18, 2025

    @The-Compiler
    The-Compiler
    on Jun 18, 2025
    Member
    More actions

    In pytest 7.2.2 (or when removing fixB), this results in 1 passed, 1 skipped (which is somewhat confusing but another long-standing issue).

    With pytest 7.3.0 and later, this errors in the same way you mention. Bisected to 3a68c08:

    • Use exceptiongroup for multiple errors during teardown #10226

    And I think your guess is spot-on, e.g. around here:

    pytest/src/_pytest/runner.py

    Lines 398 to 410 in b3ee80b

    skip_exceptions = [Skipped]
    unittest = sys.modules.get("unittest")
    if unittest is not None:
    skip_exceptions.append(unittest.SkipTest)
    if isinstance(call.excinfo.value, tuple(skip_exceptions)):
    outcome = "skipped"
    r_ = collector._repr_failure_py(call.excinfo, "line")
    assert isinstance(r_, ExceptionChainRepr), repr(r_)
    r = r_.reprcrash
    assert r
    longrepr = (str(r.path), r.lineno, r.message)
    else:
    outcome = "failed"

    I suspect this might also happen with other outcome exceptions. Maybe we should immediately raise the first outcome exception as a special case rather than grouping those? Perhaps conditionally as long as there are no other non-outcome exceptions that happened?

    cc @Zac-HD @jakkdl who did a lot of work around exception groups

  3. The-Compiler
    added
    type: bugproblem that needs to be addressed
    topic: tracebacksrelated to displaying and handling of tracebacks
    type: regressionindicates a problem that was introduced in a release which was working previously
    on Jun 18, 2025
  4. RonnyPfannschmidt commented on Jun 18, 2025

    @RonnyPfannschmidt
    RonnyPfannschmidt
    on Jun 18, 2025
    Member
    More actions

    We should consider exception group's with only skip as skip

    Reacted by Zac Hatfield-Dodds
  5. ego-thales commented on Jun 18, 2025

    @ego-thales
    ego-thales
    on Jun 18, 2025
    Author
    More actions

    Ok great!

    Maybe we should immediately raise the first outcome exception as a special case rather than grouping those? Perhaps conditionally as long as there are no other non-outcome exceptions that happened?

    I was thinking about this and I don't think the desired behaviour is trivial to define. For example, we might want to skip if there are only skips, but we might also want to allow fixtures to skip even if an inner fixture failed? Like a kind of "catching fixture". It seems far fetched, but I think there's potentially something to clarify here.

    Also, we might want to skip at the first skip encountered, OR we might want to allow outermost fixture to still fail the test even if an inner fixture skipped it?

    So as I see it, it's a discussion that needs to happen.

  6. RonnyPfannschmidt commented on Jun 18, 2025

    @RonnyPfannschmidt
    RonnyPfannschmidt
    on Jun 18, 2025
    Member
    More actions

    The groupings was added so exceptions no longer get lost

    Now we need to account for that in places

  7. Zac-HD commented on Jun 18, 2025

    @Zac-HD
    Zac-HD
    on Jun 18, 2025
    Member
    More actions
    if isinstance(exc := call.excinfo.value, tuple(skip_exceptions)) or (
        isinstance(exc, BaseExceptionGroup) and exc.subgroup(skip_exceptions)
    ):

    once we drop Python 3.10, the new except* syntax should also make it easier.

  8. RonnyPfannschmidt commented on Jun 20, 2025

    @RonnyPfannschmidt
    RonnyPfannschmidt
    on Jun 20, 2025
    Member
    More actions

    I did a quick excursion to exitstack

    Exitstack nests the errors by manipulation of the context so it behaves as if it was nested

    We should consider whether we want that or groups in general

    Based on the behavior of exception groups i slightly prefer the idea of eventually handling those from groups

  9. Zac-HD commented on Jun 20, 2025

    @Zac-HD
    Zac-HD
    on Jun 20, 2025
    Member
    More actions

    We'll need to handle ExceptionGroups anyway, in case the user calls pytest.skip() from inside an asyncio.TaskGroup context manager (among other cases)

  10. RonnyPfannschmidt commented on Jun 20, 2025

    @RonnyPfannschmidt
    RonnyPfannschmidt
    on Jun 20, 2025
    Member
    More actions

    Good point

  11. gomri15 commented on Sep 18, 2025

    @gomri15
    gomri15
    on Sep 18, 2025
    Contributor
    More actions

    would love to take a crack at this now that i've made some progress with pytest.exit().
    could you assign it to me and in general should i wait to be assigned to something before i start working on it?

  12. Zac-HD commented on Sep 18, 2025

    @Zac-HD
    Zac-HD
    on Sep 18, 2025
    Member
    More actions

    open source projects almost never assign issues - it's very rare to see duplicate PRs for an issue more than a few days old, and so it's not worth the overhead in notifications etc. Which means, feel free to just open a PR!

  13. gomri15
    added a commit that references this issue on Sep 21, 2025

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit 91f73f4 is merged into the 'main' branch.
    91f73f4
  14. 2 remaining items

  15. gomri15
    added 3 commits that reference this issue on Sep 21, 2025

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit 0380548 is merged into the 'main' branch.
    0380548

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit 90fba0d is merged into the 'main' branch.
    90fba0d

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit 959a89f is merged into the 'main' branch.
    959a89f
  16. gomri15
    added 5 commits that reference this issue on Oct 15, 2025

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit 6ed264c is merged into the 'main' branch.
    6ed264c

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit 9adef4b is merged into the 'main' branch.
    9adef4b

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit 2d37732 is merged into the 'main' branch.
    2d37732

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit 11ad3fb is merged into the 'main' branch.
    11ad3fb

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit ff07ff6 is merged into the 'main' branch.
    ff07ff6
  17. Zac-HD
    closed this as completedin e26c0aeon Oct 28, 2025
  18. pull
    added a commit that references this issue on Oct 28, 2025

    fix pytest-dev#13537: Add support for ExceptionGroup with only Skippe…

    This issue will close once commit e26c0ae is merged into the 'main' branch.
    e26c0ae
  19. 736-c41-2c1-e464fc974
    added 2 commits that reference this issue on Feb 4, 2026

    chore(deps): update pytest (major)

    01f4e67

    Merge branch 'renovate/pytest-9.x' into 'main'

    d08c4bc
  20. MateoGreil
    added a commit that references this issue on Jul 4, 2026

    🔒️ Update dependency pytest to v9 [SECURITY] (#16)

    d97ea28
  21. luketainton
    added a commit that references this issue on Jul 19, 2026

    [SECURITY] Update dependency pytest to v9 [SECURITY] (#2)

    fca183b
  22. Djeex
    added a commit that references this issue on Aug 31, 2026

    Update dependency pytest to v9 (#35)

    f96ce2f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: tracebacksrelated to displaying and handling of tracebackstype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.