Codex/assertion text diff blocks#14425
Open
hamza-mobeen wants to merge 6 commits intopytest-dev:mainfrom
Open
Conversation
Closes pytest-dev#8395 Co-authored-by: Antigravity <antigravity@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #6757
Description
This PR introduces a new configuration option,
assertion_text_diff_style, to allow users to customize how multiline string assertion failures are displayed.As highlighted in #6757, when
pytestusesndiffto display differences for multiline strings (like output fromcapsys), it can sometimes become an unreadable "soup", especially when changes involve indentation or leading/trailing whitespace. The current behavior often results in a confusing line-by-line diff that is difficult to parse.This PR adds an optional
blockdiff style that displays the exact contents of the "Left" and "Right" text blocks intact and sequentially, making it significantly easier to read the literal multiline strings being compared without the interspersedndiffnoise.Key changes:
assertion_text_diff_styleconfiguration option. Defaults tondiffto preserve backwards compatibility.blockdiff style (_diff_text_block) for multiline string comparisons, solving the readability issue raised in assertion diffs for multiline-string can become unreadable soup #6757.ndiffeven ifblockis selected.assertion_text_diff_styleis eitherndifforblock.testing/test_assertion.pyverifying block formatting, fallback logic, blank line handling, and configuration validation.Checklist
closes #XYZWto the PR description and/or commits (whereXYZWis the issue number).Co-authored-bycommit trailers.changelogdirectory, with a name like<ISSUE NUMBER>.<TYPE>.rst.AUTHORSin alphabetical order.