def test_get_class_parents(self): node1 = Node('f') node2 = Node('f', [node1]) node3 = Node('f') node4 = Node('f', [node3]) # Without setting anything else, there are no parents. self.assertEqual(node1.get_class_parents(), {node2}) self.assertEqual(node2.get_class_parents(), set()) self.assertEqual(node3.get_class_parents(), {node4}) self.assertEqual(node4.get_class_parents(), set()) # Attention: Changing the find value will not change the parents sets! node2.find = node1 node4.find = node3 self.assertEqual(node1.get_class_parents(), {node2}) self.assertEqual(node2.get_class_parents(), {node2}) self.assertEqual(node3.get_class_parents(), {node4}) self.assertEqual(node4.get_class_parents(), {node4}) node3.find = node1 self.assertEqual(node1.get_class_parents(), {node2}) self.assertEqual(node2.get_class_parents(), {node2}) self.assertEqual(node3.get_class_parents(), {node2}) self.assertEqual(node4.get_class_parents(), {node2})
def test_get_class_representative(self): node1 = Node('f') node2 = Node('f') node3 = Node('f') node4 = Node('f') # Without setting anything else, all nodes are their own # representatives. self.assertEqual(node1.get_class_representative(), node1) self.assertEqual(node2.get_class_representative(), node2) self.assertEqual(node3.get_class_representative(), node3) self.assertEqual(node4.get_class_representative(), node4) node1.find = node2 self.assertEqual(node1.get_class_representative(), node2) self.assertEqual(node2.get_class_representative(), node2) self.assertEqual(node3.get_class_representative(), node3) self.assertEqual(node4.get_class_representative(), node4) node3.find = node4 self.assertEqual(node1.get_class_representative(), node2) self.assertEqual(node2.get_class_representative(), node2) self.assertEqual(node3.get_class_representative(), node4) self.assertEqual(node4.get_class_representative(), node4) node2.find = node3 self.assertEqual(node1.get_class_representative(), node4) self.assertEqual(node2.get_class_representative(), node4) self.assertEqual(node3.get_class_representative(), node4) self.assertEqual(node4.get_class_representative(), node4)
node6.add_argument(node8) node7.add_argument(node1) node8.add_argument(node1) node10.add_argument(node11) node10.add_argument(node12) node11.add_argument(node5) node12.add_argument(node5) node13.add_argument(node6) node14.add_argument(node6) node15.add_argument(node2) node16.add_argument(node2) node17.add_argument(node10) node18.add_argument(node10) # Set the node's find values. node13.find = node7 node14.find = node8 node15.find = node3 node16.find = node4 node17.find = node11 node18.find = node12 # Create the lists to check. merge_list = [ (node1, node2), (node5, node6), (node9, node10) ] inequality_list = [ (node9, node1) ]
node6.add_argument(node8) node7.add_argument(node1) node8.add_argument(node1) node10.add_argument(node11) node10.add_argument(node12) node11.add_argument(node5) node12.add_argument(node5) node13.add_argument(node6) node14.add_argument(node6) node15.add_argument(node2) node16.add_argument(node2) node17.add_argument(node10) node18.add_argument(node10) # Set the node's find values. node13.find = node7 node14.find = node8 node15.find = node3 node16.find = node4 node17.find = node11 node18.find = node12 # Create the lists to check. merge_list = [(node1, node2), (node5, node6), (node9, node10)] inequality_list = [(node9, node1)] # Print message. print ' ... Done' print '' print 'Merging...' print '####################'