Skip to content

Conversation

@dariomesic
Copy link
Contributor

Purpose

This PR addresses a TODO in AbstractRaises._check_match (inside src/_pytest/raises.py) which noted that the error message for a regex mismatch could be confusing.

The previous message used Regex: and Input:, which could be ambiguous in failure logs.

This change updates the _fail_reason string to be more explicit:

  • Regex: -> Expected regex:
  • Input: -> Actual message:

This makes the failure message clearer and easier to debug, as requested in the code comment.

Tests

This change required updating the assertions in several tests that were checking for the exact old error message. The following test files were updated to expect the new, clearer message:

  • testing/python/raises.py
  • testing/python/raises_group.py

@dariomesic dariomesic closed this Oct 29, 2025
@dariomesic dariomesic deleted the fix-pytest-raises-error-v2 branch October 29, 2025 14:30
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.

1 participant