diff --git a/AUTHORS b/AUTHORS index dee73514a..a68b548d3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -120,6 +120,7 @@ Eduardo Schettino Eli Boyarski Elizaveta Shashkova Éloi Rivard +Emmeline Wetzel Endre Galaczi Eric Hunsberger Eric Liu @@ -219,6 +220,7 @@ Loic Esteve Lukas Bednar Luke Murphy Maciek Fijalkowski +Madeline Thai-Tang Maho Maik Figura Mandeep Bhutani diff --git a/changelog/10704.improvement.rst b/changelog/10704.improvement.rst new file mode 100644 index 000000000..657fdfce6 --- /dev/null +++ b/changelog/10704.improvement.rst @@ -0,0 +1 @@ +Changed the diff explanation for string comparison assertions when there is a tab in the string to show ``\t`` instead of `` `` diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 672d858a2..514bc8e17 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -290,10 +290,9 @@ def _diff_text(left: str, right: str, verbose: int = 0) -> List[str]: for line in ndiff(right.splitlines(keepends), left.splitlines(keepends)) ] for i in range(len(explanation)): - explanation[i] = explanation[i].replace("+ ", "+ \t") - explanation[i] = explanation[i].replace(" ", "\t") - print("**********************LOOK HERE***********************") - print(explanation) + if "? " not in explanation[i]: # dont replace diff message tab + explanation[i] = explanation[i].replace("+ ", "+ \t") + explanation[i] = explanation[i].replace(" ", "\t") return explanation