Closed pfctdayelise closed 2 years ago
I think it has not changed (but you might want to git-bisect). IIRC I've noticed this also with some PR that touched assertion rewriting.
It seems it did change, tried with an old version (3.6.0
) and I get the correct output with -v
.
Bisected to 85055a9efecfd729e73772c9c32ff8fbba18f469, introduced by https://github.com/pytest-dev/pytest/issues/2256. cc @oscarbenjamin
Some WIP at https://github.com/pytest-dev/pytest/pull/5933 (RFC).
@nicoddemus , @blueyed This is the culprit: https://github.com/pytest-dev/pytest/blob/6aaa017b1e81f6eccc48ee4f6b52d25c49747554/src/_pytest/assertion/util.py#L226-L227
elif verbose > 0:
explanation = _compare_eq_verbose(left, right)
That's why the failed test diff output is less verbose with -v
(or -vv
) than not using -v
. I'd assume we just want to remove those lines so that we maintain the default behavior of having verbose diffs, which is what most people want. I also noticed that the tests are incorrect, which is why this issue wasn't caught in the first place.
I might need to revise my solution above. It'll work for an assertion such as assert len(s) == 1
, where the default verbosity diff is more verbose than using -v
or -vv
, but that's not the same effect as assertions of other data types.
Hi @mdmintz,
Thanks for bringing this up.
I'm opening a PR applying your suggestion above, plus another small bug that I found during my testing.
We can discuss this over the code. 👍
I don't know if this has changed recently but it seems in some cases using -v makes the output less verbose...
Normal output
Output with -v
Calling it with higher levels of verbosity (-vv, -vvv) has the same output as -v.
Using pytest 4.4.1.