]>
git.madduck.net Git - etc/vim.git/blobdiff - tests/util.py
madduck's git repository
Every one of the projects in this repository is available at the canonical
URL git://git.madduck.net/madduck/pub/<projectpath> — see
each project's metadata for the exact URL.
All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@ git. madduck. net .
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
SSH access, as well as push access can be individually
arranged .
If you use my repositories frequently, consider adding the following
snippet to ~/.gitconfig and using the third clone URL listed for each
project:
[url "git://git.madduck.net/madduck/"]
insteadOf = madduck:
from black.mode import TargetVersion
from black.output import diff, err, out
from black.mode import TargetVersion
from black.output import diff, err, out
+from . import conftest
+
PYTHON_SUFFIX = ".py"
ALLOWED_SUFFIXES = (PYTHON_SUFFIX, ".pyi", ".out", ".diff", ".ipynb")
PYTHON_SUFFIX = ".py"
ALLOWED_SUFFIXES = (PYTHON_SUFFIX, ".pyi", ".out", ".diff", ".ipynb")
def _assert_format_equal(expected: str, actual: str) -> None:
def _assert_format_equal(expected: str, actual: str) -> None:
- if actual != expected and not os.environ.get("SKIP_AST_PRINT" ):
+ if actual != expected and (conftest.PRINT_FULL_TREE or conftest.PRINT_TREE_DIFF ):
- out("Expected tree:", fg="green")
+ actual_out: str = ""
+ expected_out: str = ""
+ if conftest.PRINT_FULL_TREE:
+ out("Expected tree:", fg="green")
try:
exp_node = black.lib2to3_parse(expected)
try:
exp_node = black.lib2to3_parse(expected)
+ bdv = DebugVisitor(print_output=conftest.PRINT_FULL_TREE )
list(bdv.visit(exp_node))
list(bdv.visit(exp_node))
+ expected_out = "\n".join(bdv.list_output)
except Exception as ve:
err(str(ve))
except Exception as ve:
err(str(ve))
- out("Actual tree:", fg="red")
+ if conftest.PRINT_FULL_TREE:
+ out("Actual tree:", fg="red")
try:
exp_node = black.lib2to3_parse(actual)
try:
exp_node = black.lib2to3_parse(actual)
+ bdv = DebugVisitor(print_output=conftest.PRINT_FULL_TREE )
list(bdv.visit(exp_node))
list(bdv.visit(exp_node))
+ actual_out = "\n".join(bdv.list_output)
except Exception as ve:
err(str(ve))
except Exception as ve:
err(str(ve))
+ if conftest.PRINT_TREE_DIFF:
+ out("Tree Diff:")
+ out(
+ diff(expected_out, actual_out, "expected tree", "actual tree")
+ or "Trees do not differ"
+ )
if actual != expected:
out(diff(expected, actual, "expected", "actual"))
if actual != expected:
out(diff(expected, actual, "expected", "actual"))