Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When multiple fixture finalizers raise, only first exception is reported #12047

Closed
bluetech opened this issue Mar 2, 2024 · 0 comments · Fixed by #12048
Closed

When multiple fixture finalizers raise, only first exception is reported #12047

bluetech opened this issue Mar 2, 2024 · 0 comments · Fixed by #12048
Assignees
Labels
topic: fixtures anything involving fixtures directly or indirectly topic: reporting related to terminal output and user-facing messages and errors

Comments

@bluetech
Copy link
Member

bluetech commented Mar 2, 2024

As mentioned in the XXX comment here:

pytest/src/_pytest/fixtures.py

Lines 1019 to 1032 in 6ed0051

def finish(self, request: SubRequest) -> None:
exc = None
try:
while self._finalizers:
try:
func = self._finalizers.pop()
func()
except BaseException as e:
# XXX Only first exception will be seen by user,
# ideally all should be reported.
if exc is None:
exc = e
if exc:
raise exc

This means information on the extra errors that occurred is not reported, which should never happen ideally.

We should instead raise an exception group in this case, like we do for nodes since pytest 7.3 (#10226).

@bluetech bluetech added topic: reporting related to terminal output and user-facing messages and errors topic: fixtures anything involving fixtures directly or indirectly labels Mar 2, 2024
@bluetech bluetech self-assigned this Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: fixtures anything involving fixtures directly or indirectly topic: reporting related to terminal output and user-facing messages and errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant