MCPcopy Index your code
hub / github.com/python/cpython / _test_graph

Method _test_graph

Lib/test/test_graphlib.py:8–27  ·  view source on GitHub ↗
(self, graph, expected)

Source from the content-addressed store, hash-verified

6
7class TestTopologicalSort(unittest.TestCase):
8 def _test_graph(self, graph, expected):
9 def static_order_with_groups(ts):
10 ts.prepare()
11 while ts.is_active():
12 nodes = ts.get_ready()
13 for node in nodes:
14 ts.done(node)
15 yield tuple(sorted(nodes))
16
17 ts = graphlib.TopologicalSorter(graph)
18 self.assertEqual(list(static_order_with_groups(ts)), list(expected))
19
20 ts = graphlib.TopologicalSorter(graph)
21 # need to be a bit careful comparing the result of ts.static_order and
22 # expected, because the order within a group is dependent on set
23 # iteration order
24 it = iter(ts.static_order())
25 for group in expected:
26 tsgroup = {next(it) for element in group}
27 self.assertEqual(set(group), tsgroup)
28
29 def _assert_cycle(self, graph, cycle):
30 ts = graphlib.TopologicalSorter()

Callers 4

test_simple_casesMethod · 0.95
test_no_dependenciesMethod · 0.95
test_emptyMethod · 0.95

Calls 4

static_orderMethod · 0.95
listClass · 0.85
setFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected