Skip to content

feat: aggregate expect.soft() failures per test#312

Open
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Skn0tt:feat/soft-assertions
Open

feat: aggregate expect.soft() failures per test#312
Skn0tt wants to merge 2 commits intomicrosoft:mainfrom
Skn0tt:feat/soft-assertions

Conversation

@Skn0tt
Copy link
Copy Markdown
Member

@Skn0tt Skn0tt commented May 4, 2026

Summary

Companion PR (core hook): microsoft/playwright-python#3065

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).
return
if len(errors) == 1:
raise errors[0]
raise _BaseExceptionGroup("Soft assertion failures", errors)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what happens if the test has a soft failure followed by the hard failure? Are we going to see both errors?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, see test_soft_assertion_does_not_shadow_body_failure

Copy link
Copy Markdown

@dgozman dgozman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good. It would be nice to include pytest output in the description, to see how it looks like for the user.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants