(expected: str, actual: str)
| 34 | |
| 35 | |
| 36 | def _assert_format_equal(expected: str, actual: str) -> None: |
| 37 | if actual != expected and not os.environ.get("SKIP_AST_PRINT"): |
| 38 | bdv: DebugVisitor[Any] |
| 39 | out("Expected tree:", fg="green") |
| 40 | try: |
| 41 | exp_node = black.lib2to3_parse(expected) |
| 42 | bdv = DebugVisitor() |
| 43 | list(bdv.visit(exp_node)) |
| 44 | except Exception as ve: |
| 45 | err(str(ve)) |
| 46 | out("Actual tree:", fg="red") |
| 47 | try: |
| 48 | exp_node = black.lib2to3_parse(actual) |
| 49 | bdv = DebugVisitor() |
| 50 | list(bdv.visit(exp_node)) |
| 51 | except Exception as ve: |
| 52 | err(str(ve)) |
| 53 | |
| 54 | if actual != expected: |
| 55 | out(diff(expected, actual, "expected", "actual")) |
| 56 | |
| 57 | assert actual == expected |
| 58 | |
| 59 | |
| 60 | class FormatFailure(Exception): |
no test coverage detected