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.
This commit is contained in:
Nipunn Koorapati 2021-10-27 07:37:20 -07:00 committed by GitHub
parent 26970742b7
commit aedb4ff7f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@
import black import black
from black.debug import DebugVisitor from black.debug import DebugVisitor
from black.mode import TargetVersion from black.mode import TargetVersion
from black.output import err, out from black.output import diff, err, out
THIS_DIR = Path(__file__).parent THIS_DIR = Path(__file__).parent
DATA_DIR = THIS_DIR / "data" DATA_DIR = THIS_DIR / "data"
@ -47,6 +47,9 @@ def _assert_format_equal(expected: str, actual: str) -> None:
except Exception as ve: except Exception as ve:
err(str(ve)) err(str(ve))
if actual != expected:
out(diff(expected, actual, "expected", "actual"))
assert actual == expected assert actual == expected