| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
At the default verbosity the displayed assertion explanation is truncated to a handful of lines, but ``_diff_text`` always ran ``difflib.ndiff`` over the full strings first. For multi-million-line strings this could take hours (difflib's runtime blows up on large inputs), only for almost all of the output to be discarded. Now, when ``verbose < 1``, the diff is computed over at most the first 100 lines of each side (after the existing identical leading/trailing character skipping), with a message pointing at ``-v`` to get the full diff. This mirrors the existing behaviour of skipping identical leading/trailing characters unless ``-v`` is given, and the precedent of ``_compare_eq_iterable`` not computing a full diff at low verbosity. The message starts with "Skipping" so that ``_notin_text``'s existing filtering drops it there, like the other skip hints. Fixes pytest-dev#12406 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVRWXxfTLrU4B95jeoeuHN
|
More conservative approach than #14543 that keep the exact output even when it would take a lot of time to generate ? (Might not fix #8998) |
Sorry, something went wrong.
|
Also, if you're interested in making assertion message faster there's also #14523 that is very impactful on everything but the ndiff part when the verbosity is low and the assert message will be truncated :) |
Sorry, something went wrong.
|
Closing this in favor of #14543; my patch would not handle the case of very long individual lines, and I'm happy to defer to work already in flight. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
At the default verbosity the displayed assertion explanation is truncated to a handful of lines, but _diff_text always ran difflib.ndiff over the full strings first. For multi-million-line strings this could take hours (difflib's runtime blows up on large inputs), only for almost all of the output to be discarded.
Now, when verbose < 1, the diff is computed over at most the first 100 lines of each side (after the existing identical leading/trailing character skipping), with a message pointing at -v to get the full diff. This mirrors the existing behaviour of skipping identical leading/trailing characters unless -v is given, and the precedent of _compare_eq_iterable not computing a full diff at low verbosity.
The message starts with "Skipping" so that _notin_text's existing filtering drops it there, like the other skip hints.
Fixes #12406