-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Better diffs in tests #16112
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
Better diffs in tests #16112
Conversation
It's annoying that one line change causes everything else to show up as a diff. Just use difflib instead. I also highlight the changed lines. We can't use FancyFormatter because it doesn't work well with pytest.
for more information, see https://pre-commit.ci
Add a test to mypy/test/meta/? |
Can you show some examples? One the goals of the existing diffing approach is to make it easy to copy-paste the actual output from running a test to a test case description with only minor editing required. I'd like to preserve that. I often leave the output of a test case empty, run the test case, and after validating that the output looks good copy the output into the test case. |
@JukkaL did you try |
It's pretty handy, but I only tend to use it for bulk updates. If I'm working on a single test case I tend to use copy-paste a lot, in part because I can never remember the name of the flag without looking it up. :) |
Okay I changed it to also mention |
Speaking of I couldn't find a way to trigger We can rewrite Or keep the wart (maybe then say "Update the test output using -n0 --update-data"). |
I'm merging, since I keep wanting this for other PRs I'm working on. I will add a unit test for the diff logic + any other feedback in follow up. If it helps I use similar code elsewhere + this logic never changes test results, so am pretty confident |
Follow up to python#16112
Follow up to python#16112
It's annoying that one line change causes everything else to show up as a diff. Just use difflib instead. I also highlight the changed lines. We can't use FancyFormatter because it doesn't work well with pytest.