-
Notifications
You must be signed in to change notification settings - Fork 38
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
Readable test diffs with pytest-icdiff #1955
Conversation
Code Climate has analyzed commit 6db2b41 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 75.3% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your PR. I had a little read on pytest-diff, and as for me we can try this out. But it would be good if someone with more experience on this could also have a look :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 👍
In general I agree that the current test output isn't ideal and I'm fine with changing it (and we also don't parse this anywhere).
I'm not sure what I'm doing wrong, but somehow I cannot get this to work... I just changed a few small details in the expected API output, and the error still looks very unreadable:
> assert result == response.json()
E AssertionError: assert
E [{'id': 35, 'url': 'http://localhost:8000/augsburg/de/behörden-und-beratung/behörden/', 'path': '/augsburg/de/behörden-und-beratung/behörden/', 'title': 'Behörden', 'modified_gmt': '2022-01-16T16:36:57.038Z', 'last_updated': '2022-01-16T17:36:57.038+01:00', 'excerpt': '', 'content': '', 'parent': {'id': 14, 'url': 'http://localhost:8000/augsburg/de/behörden-und-beratung/', 'path': '/augsburg/de/behörden-und-beratung/'}, 'order': 2, 'available_languages': {'en': {'id': 47, 'url': 'http://localhost:8000/augsburg/en/authorities-and-counselling/public-authorities/', 'path': '/augsburg/en/authorities-and-counselling/public-authorities/'}...
E
E ...Full output truncated (11 lines hidden), use '-vv' to show
tests/api/test_api_result.py:46: AssertionError
And I'm pretty sure it looked exactly the same before. But maybe I have a different problem, does it work for you?
Also, I think the dependency itself isn't a good choice, mainly for these reasons:
- It's only version number
0.1.14
and hasn't been updated for over three years, so probably it died during early development stage - The author of the package either deleted or renamed their GitHub username (https://github.com/username/pytest-diff isn't reachable anymore), so not sure where any maintenance would happen... If you think we should use this dependency nevertheless, I'd suggest you download the source code, create a new repository under the Digitalfabrik orga and we start maintaining this dependency ourselves. But probably this isn't worth the effort, maybe you could do a little bit of research to find a different package? Or maybe simply adding
-vv
as the error message suggests works as well?
Apart from that, the dev dependencies also need to be added to the Pipfile.lock, only adding them to the Pipfile leads to an inconsistent state and means that we don't install the same dependency versions on all machines anymore.
So please run pipenv install --dev <package-name>
as described in the docs to update the lockfile as well, thanks!
Considering the state of pytest-diff, do you intend to continue with this PR? Otherwise we can probably close it and revisit the issue another time? |
Thank you for your patience! I did a bit more research and compiled some screenshots. For the sake of comparison, this is how it looks currently: And this is how it looks with But, Lastly, there is My personal verdict is that I like What I have not been able to figure out is how exactly running pytest as part of the
directly. Running If you like the approach and think figuring out the last part won't take too much effort, I'll continue with this, otherwise we can close this. |
Thanks for revisiting this! 👍
I agree, this tools looks very promising!
Both problems seems to be caused by an incompatibility between pytest-icdiff and pytest-xdist. I suggest to:
|
0e81e28
to
9dc2cc6
Compare
Found out that getting the colored output seems to be as easy as adding I'd also like to wait until #2027 is merged |
8857ae4
to
d6873d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, makes sense! 👍
Could you also document the new verbose flags and mention that they implicate performance drawbacks?
3a0ef03
to
5b82fcb
Compare
dev-tools/test.sh: force color, enable -vv (and disable parallel processing if used)
5b82fcb
to
6db2b41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Short description
This PR makes the output of failed API tests legible, by producing deep diffs of the JSON responses. It is possible to quickly see which values differ from the expected output.
Proposed changes
Side effects
Resolved issues
Fixes: #1953
Pull Request Review Guidelines