feat: aggregate expect.soft() failures per test#312
Open
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Open
feat: aggregate expect.soft() failures per test#312Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Adds an autouse function-scoped fixture in both pytest-playwright and pytest-playwright-asyncio that wraps each test in a soft-assertion collection scope. At end of test, collected failures are re-raised: zero → noop, one → re-raise, multiple → BaseExceptionGroup. Requires playwright-python with the soft-assertions hook (microsoft/playwright-python#1272).
dgozman
reviewed
May 5, 2026
| return | ||
| if len(errors) == 1: | ||
| raise errors[0] | ||
| raise _BaseExceptionGroup("Soft assertion failures", errors) |
There was a problem hiding this comment.
I wonder what happens if the test has a soft failure followed by the hard failure? Are we going to see both errors?
Member
Author
There was a problem hiding this comment.
yes, see test_soft_assertion_does_not_shadow_body_failure
dgozman
approved these changes
May 5, 2026
dgozman
left a comment
There was a problem hiding this comment.
The code looks good. It would be nice to include pytest output in the description, to see how it looks like for the user.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pytest-playwrightandpytest-playwright-asynciothat wraps each test in a soft-assertion collection scope.BaseExceptionGroup.playwright-pythonwith the soft-assertions hook (feat(assertions): add expect.soft() for collecting multiple failures playwright-python#3065).Companion PR (core hook): microsoft/playwright-python#3065