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

Method test_cycle

Lib/test/test_graphlib.py:116–128  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

114 self._test_graph({}, [])
115
116 def test_cycle(self):
117 # Self cycle
118 self._assert_cycle({1: {1}}, [1, 1])
119 # Simple cycle
120 self._assert_cycle({1: {2}, 2: {1}}, [1, 2, 1])
121 # Indirect cycle
122 self._assert_cycle({1: {2}, 2: {3}, 3: {1}}, [1, 3, 2, 1])
123 # not all elements involved in a cycle
124 self._assert_cycle({1: {2}, 2: {3}, 3: {1}, 5: {4}, 4: {6}}, [1, 3, 2, 1])
125 # Multiple cycles
126 self._assert_cycle({1: {2}, 2: {1}, 3: {4}, 4: {5}, 6: {7}, 7: {6}}, [1, 2, 1])
127 # Cycle in the middle of the graph
128 self._assert_cycle({1: {2}, 2: {3}, 3: {2, 4}, 4: {5}}, [3, 2])
129
130 def test_calls_before_prepare(self):
131 ts = graphlib.TopologicalSorter()

Callers

nothing calls this directly

Calls 1

_assert_cycleMethod · 0.95

Tested by

no test coverage detected