Skip to content

Conversation

@dariomesic
Copy link
Contributor

@dariomesic dariomesic commented Oct 29, 2025

Purpose

This PR addresses a suggestion 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 force-pushed the fix-pytest-raises-error-v3 branch from 31f3127 to 7a95a71 Compare October 29, 2025 14:30
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 29, 2025
@dariomesic dariomesic force-pushed the fix-pytest-raises-error-v3 branch from 7fc5e67 to 8d55ab0 Compare October 29, 2025 14:31
@dariomesic dariomesic force-pushed the fix-pytest-raises-error-v3 branch from 2636b34 to 12d3ce1 Compare October 29, 2025 15:02
@dariomesic dariomesic marked this pull request as ready for review October 29, 2025 15:17
Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Thanks!

@bluetech bluetech merged commit b3f3263 into pytest-dev:main Oct 29, 2025
62 checks passed
@dariomesic dariomesic deleted the fix-pytest-raises-error-v3 branch October 29, 2025 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants