Skip to content

Commit

Permalink
Print out line diff on test failure (#2552)
Browse files Browse the repository at this point in the history
It currently prints both ASTs - this also
adds the line diff, making it much easier to visualize
the changes as well. Not too verbose since it's only a diff.
  • Loading branch information
nipunn1313 authored and JelleZijlstra committed Nov 16, 2021
1 parent 3969b9f commit 1607b79
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import black
from black.debug import DebugVisitor
from black.mode import TargetVersion
from black.output import err, out
from black.output import diff, err, out

THIS_DIR = Path(__file__).parent
DATA_DIR = THIS_DIR / "data"
Expand Down Expand Up @@ -47,6 +47,9 @@ def _assert_format_equal(expected: str, actual: str) -> None:
except Exception as ve:
err(str(ve))

if actual != expected:
out(diff(expected, actual, "expected", "actual"))

assert actual == expected


Expand Down

0 comments on commit 1607b79

Please sign in to comment.