def testCopy(self): b = BlockInfo(None, "/Foo", False, "") b.addUserParam("p0", "val0") b.addUserParam("p1", "val1") b2 = BlockInfo(None, "/Foo/bar", False, "") b2.addUserParam("p2", "val2") b2.addUserParam("p3", "val3") b3 = BlockInfo(None, "/Foo/bar1", False, "") b3.addUserParam("p4", "val4") b3.addUserParam("p5", "val5") b.addChildBlock(b2) b.addChildBlock(b3) b.setStarInfo(BlockInfo(None, "Foo/star", False, "")) b.addBlockType(BlockInfo(None, "Foo/t", False, "")) b_copy = b.copy(None) self.assertNotEqual(b_copy, b) self.assertEqual(b_copy.name, b.name) self.assertEqual(b_copy.types.keys(), b.types.keys()) self.assertNotEqual(b_copy.types, b.types) self.assertEqual(b_copy.children.keys(), b.children.keys()) self.assertEqual(b_copy.children_list, b.children_list) self.assertEqual(b_copy.parameters_list, b.parameters_list) self.assertEqual(b_copy.parameters.keys(), b.parameters.keys()) o = b.dump() o1 = b_copy.dump() self.assertEqual(o, o1)
def testBasic(self): b = BlockInfo(None, "/Foo", False, "") b1 = BlockInfo(None, "/Foo/bar", False, "") b.addChildBlock(b1) self.assertEqual(b1.parent, b) self.assertIn(b1.name, b.children_list) self.assertIn(b1.name, b.children) b.types[b1.name] = b1 b.star_node = b1 out = b.dump() self.assertIn("/Foo/bar", out)