-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
objects with multiline repr cause pytest to print a diff #73
Comments
Another similar example: def test_obj():
result = {
"person": {
"foo": "bar",
"ready": False,
"list": [
"xxx",
"xxx",
"xxx",
"xxx",
"xxx",
"xxx",
"xxx",
"xxx",
"xxx",
"xxx",
],
},
}
assert result == {"person": AnyThing(), "xxx": "yyy"} |
pytest is using |
I did this in alexmojaki#1. Now it gives the right diff in the first example:
|
This is nice, thanks! It solves at least some of the cases. Although in my (private) code, I have a more complex test that still shows spurious changes. If I manage to reproduce in a simple test case, I'll post it, maybe in another bug. |
This prints:
The 0 vs 9 at the end is the only real diff. But I also get a lot of noise due to the long list before. The differences are just formatting, they are not real differences. They seem to stem from the fact that dirty_equals formats long lists differently from pytest (7.1.3).
If the list is short all is well, the problem only occurs when the list is long and pytest decides to format it with one element in each line.
I've been trying for a little bit to come up with a possible fix for this, to no avail. Does not seem to be a simple fix. I am not sure if it is possible to fix this. But it bothers me a lot and I am willing to try. Any advice is welcome.
The text was updated successfully, but these errors were encountered: