From aedb4ff7f061b321ea5804bc4fc4943c52c6a786 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Wed, 27 Oct 2021 07:37:20 -0700 Subject: [PATCH 1/1] Print out line diff on test failure (#2552) 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. --- tests/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/util.py b/tests/util.py index 84e98bb..8755111 100644 --- a/tests/util.py +++ b/tests/util.py @@ -9,7 +9,7 @@ from typing import Any, Iterator, List, Optional, Tuple 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" @@ -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 -- 2.39.5