def setUp(self):
     # set up a sample tree with three children, each having
     # five string leaves and some have references to other children
     TreeTest.sample_tree = refbrowser._Node('root')
     branch1 = refbrowser._Node('branch1')
     TreeTest.sample_tree.children.append(branch1)
     branch2 = refbrowser._Node('branch2')
     TreeTest.sample_tree.children.append(branch2)
     branch3 = refbrowser._Node('branch3')
     TreeTest.sample_tree.children.append(branch3)
     branch2.children.append(branch3)
     branch3.children.append(branch1)
     for i in ['a','b','c','d','e']:
         branch1.children.append(i)
         branch2.children.append(i)
         branch3.children.append(i)
    def test_node(self):
        """Test node functionality.

        _Nodes can be created, linked to each other, and the output function
        should return the expected result.

        """
        # default representation
        n = refbrowser._Node(1)
        expected = str(1)
        self.assert_(str(n) == expected)
        # custom representation
        expected = 'the quick brown fox'
        def foo(o): return expected
        n = refbrowser._Node(1, foo)
        self.assert_(str(n) == expected)
        # attach child
        n.children.append(2)