File: unittest_graph.py

package info (click to toggle)
logilab-common 0.30.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 892 kB
  • ctags: 1,818
  • sloc: python: 9,743; makefile: 41; sh: 8
file content (21 lines) | stat: -rw-r--r-- 566 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# unit tests for the cache module

from logilab.common.testlib import TestCase, unittest_main
from logilab.common.graph import get_cycles

class getCycleTestCase(TestCase):

    def test_known0(self):
        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]])
        
    def test_known2(self):
        self.assertEqual(get_cycles({1:[2], 2:[3], 3:[0], 0:[]}), [])
        

if __name__ == "__main__":
    unittest_main()