summaryrefslogtreecommitdiff
path: root/test/test_graph.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_graph.py')
-rw-r--r--test/test_graph.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/test/test_graph.py b/test/test_graph.py
index 9a2e8bc..03ed3ef 100644
--- a/test/test_graph.py
+++ b/test/test_graph.py
@@ -20,70 +20,70 @@
from logilab.common.testlib import TestCase, unittest_main
from logilab.common.graph import get_cycles, has_path, ordered_nodes, UnorderableGraph
-class getCyclesTC(TestCase):
+class getCyclesTC(TestCase):
def test_known0(self):
- self.assertEqual(get_cycles({1:[2], 2:[3], 3:[1]}), [[1, 2, 3]])
+ self.assertEqual(get_cycles({1: [2], 2: [3], 3: [1]}), [[1, 2, 3]])
def test_known1(self):
- self.assertEqual(get_cycles({1:[2], 2:[3], 3:[1, 4], 4:[3]}), [[1, 2, 3], [3, 4]])
+ self.assertEqual(get_cycles({1: [2], 2: [3], 3: [1, 4], 4: [3]}), [[1, 2, 3], [3, 4]])
def test_known2(self):
- self.assertEqual(get_cycles({1:[2], 2:[3], 3:[0], 0:[]}), [])
+ self.assertEqual(get_cycles({1: [2], 2: [3], 3: [0], 0: []}), [])
class hasPathTC(TestCase):
-
def test_direct_connection(self):
- self.assertEqual(has_path({'A': ['B'], 'B': ['A']}, 'A', 'B'), ['B'])
+ self.assertEqual(has_path({"A": ["B"], "B": ["A"]}, "A", "B"), ["B"])
def test_indirect_connection(self):
- self.assertEqual(has_path({'A': ['B'], 'B': ['A', 'C'], 'C': ['B']}, 'A', 'C'), ['B', 'C'])
+ self.assertEqual(has_path({"A": ["B"], "B": ["A", "C"], "C": ["B"]}, "A", "C"), ["B", "C"])
def test_no_connection(self):
- self.assertEqual(has_path({'A': ['B'], 'B': ['A']}, 'A', 'C'), None)
+ self.assertEqual(has_path({"A": ["B"], "B": ["A"]}, "A", "C"), None)
def test_cycle(self):
- self.assertEqual(has_path({'A': ['A']}, 'A', 'B'), None)
+ self.assertEqual(has_path({"A": ["A"]}, "A", "B"), None)
-class ordered_nodesTC(TestCase):
+class ordered_nodesTC(TestCase):
def test_one_item(self):
- graph = {'a':[]}
+ graph = {"a": []}
ordered = ordered_nodes(graph)
- self.assertEqual(ordered, ('a',))
+ self.assertEqual(ordered, ("a",))
def test_single_dependency(self):
- graph = {'a':['b'], 'b':[]}
+ graph = {"a": ["b"], "b": []}
ordered = ordered_nodes(graph)
- self.assertEqual(ordered, ('a','b'))
- graph = {'a':[], 'b':['a']}
+ self.assertEqual(ordered, ("a", "b"))
+ graph = {"a": [], "b": ["a"]}
ordered = ordered_nodes(graph)
- self.assertEqual(ordered, ('b','a'))
+ self.assertEqual(ordered, ("b", "a"))
def test_two_items_no_dependency(self):
- graph = {'a':[], 'b':[]}
+ graph = {"a": [], "b": []}
ordered = ordered_nodes(graph)
- self.assertEqual(ordered, ('a','b'))
+ self.assertEqual(ordered, ("a", "b"))
def test_three_items_no_dependency(self):
- graph = {'a':[], 'b':[], 'c':[]}
+ graph = {"a": [], "b": [], "c": []}
ordered = ordered_nodes(graph)
- self.assertEqual(ordered, ('a', 'b', 'c'))
+ self.assertEqual(ordered, ("a", "b", "c"))
def test_three_items_one_dependency(self):
- graph = {'a': ['c'], 'b': [], 'c':[]}
+ graph = {"a": ["c"], "b": [], "c": []}
ordered = ordered_nodes(graph)
- self.assertEqual(ordered, ('a', 'b', 'c'))
+ self.assertEqual(ordered, ("a", "b", "c"))
def test_three_items_two_dependencies(self):
- graph = {'a': ['b'], 'b': ['c'], 'c':[]}
+ graph = {"a": ["b"], "b": ["c"], "c": []}
ordered = ordered_nodes(graph)
- self.assertEqual(ordered, ('a', 'b', 'c'))
+ self.assertEqual(ordered, ("a", "b", "c"))
def test_bad_graph(self):
- graph = {'a':['b']}
+ graph = {"a": ["b"]}
self.assertRaises(UnorderableGraph, ordered_nodes, graph)
+
if __name__ == "__main__":
unittest_main()