MCPcopy
hub / github.com/psf/black / _assert_format_equal

Function _assert_format_equal

tests/util.py:54–87  ·  view source on GitHub ↗
(expected: str, actual: str)

Source from the content-addressed store, hash-verified

52
53
54def _assert_format_equal(expected: str, actual: str) -> None:
55 if actual != expected and (conftest.PRINT_FULL_TREE or conftest.PRINT_TREE_DIFF):
56 bdv: DebugVisitor[Any]
57 actual_out: str = ""
58 expected_out: str = ""
59 if conftest.PRINT_FULL_TREE:
60 out("Expected tree:", fg="green")
61 try:
62 exp_node = black.lib2to3_parse(expected)
63 bdv = DebugVisitor(print_output=conftest.PRINT_FULL_TREE)
64 list(bdv.visit(exp_node))
65 expected_out = "\n".join(bdv.list_output)
66 except Exception as ve:
67 err(str(ve))
68 if conftest.PRINT_FULL_TREE:
69 out("Actual tree:", fg="red")
70 try:
71 exp_node = black.lib2to3_parse(actual)
72 bdv = DebugVisitor(print_output=conftest.PRINT_FULL_TREE)
73 list(bdv.visit(exp_node))
74 actual_out = "\n".join(bdv.list_output)
75 except Exception as ve:
76 err(str(ve))
77 if conftest.PRINT_TREE_DIFF:
78 out("Tree Diff:")
79 out(
80 diff(expected_out, actual_out, "expected tree", "actual tree")
81 or "Trees do not differ"
82 )
83
84 if actual != expected:
85 out(diff(expected, actual, "expected", "actual"))
86
87 assert actual == expected
88
89
90class FormatFailure(Exception):

Callers 2

_assert_format_innerFunction · 0.85
assertFormatEqualMethod · 0.85

Calls 5

outFunction · 0.90
DebugVisitorClass · 0.90
errFunction · 0.90
diffFunction · 0.90
visitMethod · 0.80

Tested by

no test coverage detected