Exemplo n.º 1
0
 def test_construction_acyclic(self):
     a = Node('a')
     b = Node('b', a)
     c = Node('c', b)
     try:
         a.add_parent(c)
         assert False
     except ValueError:
         assert True
Exemplo n.º 2
0
 def test_construction_index_out_of_bounds(self):
     b = Node('b')
     c = Node('c')
     try:
         c.add_parent(b, index=13)
         b._add_child(c, index=13)
         assert False
     except ValueError:
         assert True
Exemplo n.º 3
0
 def test_construction_add(self):
     b = Node('b')
     c = Node('c')
     d = Node('d')
     c.add_parent(b)
     assert c.parents == [b]
     assert b.children == [c]
     b._add_child(d)
     assert b.children == [c, d]
     assert d.parents == []  # _add_child doesn't call add_parent
Exemplo n.º 4
0
 def test_construction_add_index(self):
     b = Node('b')
     c = Node('c', b)
     d = Node('d')
     e = Node('e')
     c.add_parent(d, index=0, index_child=0)
     assert c.parents == [d, b]
     assert b.children == [c]
     assert d.children == [c]
     b._add_child(e, index=0)
     assert b.children == [e, c]
     assert e.parents == []  # _add_child doesn't call add_parent
Exemplo n.º 5
0
 def test_construction_unique(self):
     b = Node('b')
     c = Node('c', b)
     c.add_parent(b)
     assert c.parents == [b]
     assert b.children == [c]