-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Hi,
While investigating pytest.raises(..., match=...) diff behavior, I noticed that when the assertion diff truncates identical leading characters, the output includes the hint:
Skipping XX identical leading characters in diff, use -v to show
However, running with -v or -vv produces identical output -- verbosity does not seem to affect this code path.
Minimal Reproducer
import pytest, re
def test_raises_v_hint_broken():
prefix = "A" * 60
expected = prefix + " expected_ending"
actual = prefix + " actual_ending"
with pytest.raises(ValueError, match=f"^{re.escape(expected)}$"):
raise ValueError(actual)Running this produces:
AssertionError: Skipping 51 identical leading characters in diff, use -v to show
Running with -v or -vv produces identical output.
Observations
It appears _check_match() calls _diff_text() with the default verbosity (verbose=0), and verbosity from the pytest config is not propagated. _diff_text() does respect verbosity >= 1, but it never receives it in this path.
There is also a TODO in the code noting uncertainty around this behavior.
Question
Is this the intended behavior, or should verbosity be propagated so that -v actually reveals the skipped leading characters?
Happy to work on a fix if this is unintended.
Thanks!