MCPcopy Create free account
hub / github.com/dask/dask / pytest_assertrepr_compare

Function pytest_assertrepr_compare

conftest.py:72–98  ·  view source on GitHub ↗
(op, left, right)

Source from the content-addressed store, hash-verified

70
71
72def 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")

Callers

nothing calls this directly

Calls 1

_get_attrsFunction · 0.85

Tested by

no test coverage detected