def test_reorder_children(self):
     child1, child2 = Group(name='child1'), Group(name='child2')
     a = Group('a')
     a.add_child(child1)
     a.add_child(child2)
     a.reorder_children(1, 0)
     assert a.children[0].name == 'child2'
     assert a.children[1].name == 'child1'
 def test_add_self_as_child(self):
     a = Group(name='a')
     with pytest.raises(Exception):
         a.add_child(a)
 def test_replace_child(self):
     child1, child2 = Group(name='child1'), Group(name='child2')
     mid = Group(name='mid')
     mid.add_child(child1)
     mid.replace_child(child1, child2)
     assert mid.children[0].name == 'child2'
 def test_add_invalidchild(self):
     a = Group(name='a')
     with pytest.raises(TypeError):
         a.add_child("bazar")