From: Nipunn Koorapati Date: Wed, 27 Oct 2021 14:37:20 +0000 (-0700) Subject: Print out line diff on test failure (#2552) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/aedb4ff7f061b321ea5804bc4fc4943c52c6a786 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. --- 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