(op, left, right)
| 70 | |
| 71 | |
| 72 | def pytest_assertrepr_compare(op, left, right): |
| 73 | import difflib |
| 74 | |
| 75 | from dask._task_spec import Task |
| 76 | |
| 77 | if isinstance(left, Task) and isinstance(right, Task): |
| 78 | |
| 79 | def _get_attrs(node): |
| 80 | return ( |
| 81 | [ |
| 82 | str(node.func), |
| 83 | ] |
| 84 | + sorted([str(a) for a in node.args]) |
| 85 | + sorted([f"{k}: {v}" for k, v in node.kwargs.items()]) |
| 86 | ) |
| 87 | |
| 88 | diff = list( |
| 89 | difflib.ndiff( |
| 90 | _get_attrs(left), |
| 91 | _get_attrs(right), |
| 92 | ) |
| 93 | ) |
| 94 | return [ |
| 95 | "Comparing two dask graph nodes:", |
| 96 | f" left: {left.key} right: {right.key}", |
| 97 | " Diff:", |
| 98 | ] + diff |
| 99 | |
| 100 | |
| 101 | @pytest.fixture(autouse=True, scope="session") |
nothing calls this directly
no test coverage detected