Return equality of tree pairs. Each parent,children pair define a tree. The parents are assumed equal. Comparing the children dictionaries as such does not work due to comparison by identity and double linkage. We separate comparing string and numb
(parent1, children1, parent2, children2)
| 214 | expected = {'f0':f0, 'C0':C0} |
| 215 | |
| 216 | def compare(parent1, children1, parent2, children2): |
| 217 | """Return equality of tree pairs. |
| 218 | |
| 219 | Each parent,children pair define a tree. The parents are |
| 220 | assumed equal. Comparing the children dictionaries as such |
| 221 | does not work due to comparison by identity and double |
| 222 | linkage. We separate comparing string and number attributes |
| 223 | from comparing the children of input children. |
| 224 | """ |
| 225 | self.assertEqual(children1.keys(), children2.keys()) |
| 226 | for ob in children1.values(): |
| 227 | self.assertIs(ob.parent, parent1) |
| 228 | for ob in children2.values(): |
| 229 | self.assertIs(ob.parent, parent2) |
| 230 | for key in children1.keys(): |
| 231 | o1, o2 = children1[key], children2[key] |
| 232 | t1 = type(o1), o1.name, o1.file, o1.module, o1.lineno, o1.end_lineno |
| 233 | t2 = type(o2), o2.name, o2.file, o2.module, o2.lineno, o2.end_lineno |
| 234 | self.assertEqual(t1, t2) |
| 235 | if type(o1) is mb.Class: |
| 236 | self.assertEqual(o1.methods, o2.methods) |
| 237 | # Skip superclasses for now as not part of example |
| 238 | compare(o1, o1.children, o2, o2.children) |
| 239 | |
| 240 | compare(None, actual, None, expected) |
| 241 |
no test coverage detected