-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full diff thinks unittest.mock.ANY fails equality check in assertions #3638
Comments
GitMate.io thinks possibly related issues are #381 (Option to show full assertion diff), #715 (Full diff of sequences should be displayed on assertion failures when verbose), #2769 (from unittest.mock import call), #2040 (isfile check fails within pytest), and #79 (assertion rewriting fails with 'in' and 'and' operators). |
I've always found this a little confusing as well but it's also nearly impossible to fix. The "Full diff" that pytest prints here is essentially just a diff of the I agree that this is non-ideal, but I also don't think this is solvable. |
Yes, it is a well-known issue, and can be confusing with large dicts especially. The differ could maybe be a bit smarter, and inspect each key and value in the dict by itself recursively? |
It does do that for dictionaries, though for OP's case the differ is looking at a list of objects.
|
Yeah, it should do this recursively for iterables somehow. The "Full diff" could still be done like it's done for now in the end, but having the explicit "Differing items" might help to avoid confusion (and makes it easier with large diffs). |
When unittest.mock.ANY is used, and assertion fails, the pytest diff is confusing, and it mistakenly marks ANY being non-equal to the value on the other side. This is especially confusing with lists comparison. Simple example:
The full diff produced with
pytest -vv
:In the full diff you can see that not only
val
, but alsoid
is marked as being different, which is confusing, as it does not trigger the assertion. It would be a lot more clear if full diff only show the values actually comparing non-equalpytest version: 3.6.2
The text was updated successfully, but these errors were encountered: