diff --git a/tests/util.py b/tests/util.py index af86367200f..541d21da4df 100644 --- a/tests/util.py +++ b/tests/util.py @@ -12,6 +12,8 @@ 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") @@ -34,32 +36,29 @@ def _assert_format_equal(expected: str, actual: str) -> None: - # need to import inside the function for the monkeypatching tests to work - from .conftest import PRINT_FULL_TREE, PRINT_TREE_DIFF - - if actual != expected and (PRINT_FULL_TREE or PRINT_TREE_DIFF): + if actual != expected and (conftest.PRINT_FULL_TREE or conftest.PRINT_TREE_DIFF): bdv: DebugVisitor[Any] actual_out: str = "" expected_out: str = "" - if PRINT_FULL_TREE: + if conftest.PRINT_FULL_TREE: out("Expected tree:", fg="green") try: exp_node = black.lib2to3_parse(expected) - bdv = DebugVisitor(print_output=bool(PRINT_FULL_TREE)) + bdv = DebugVisitor(print_output=conftest.PRINT_FULL_TREE) list(bdv.visit(exp_node)) expected_out = "\n".join(bdv.list_output) except Exception as ve: err(str(ve)) - if PRINT_FULL_TREE: + if conftest.PRINT_FULL_TREE: out("Actual tree:", fg="red") try: exp_node = black.lib2to3_parse(actual) - bdv = DebugVisitor(print_output=bool(PRINT_FULL_TREE)) + bdv = DebugVisitor(print_output=conftest.PRINT_FULL_TREE) list(bdv.visit(exp_node)) actual_out = "\n".join(bdv.list_output) except Exception as ve: err(str(ve)) - if PRINT_TREE_DIFF: + if conftest.PRINT_TREE_DIFF: out("Tree Diff:") out( diff(expected_out, actual_out, "expected tree", "actual tree")