MCPcopy Index your code
hub / github.com/python/cpython / compare

Method compare

Lib/test/test_pyclbr.py:216–238  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 15

test_added_tab_hintMethod · 0.45
test_one_insertMethod · 0.45
test_one_deleteMethod · 0.45
test_named_parametersMethod · 0.45
test_compare_basicsMethod · 0.45
test_compare_literalsMethod · 0.45
test_compare_modesMethod · 0.45

Calls 5

compareFunction · 0.85
assertEqualMethod · 0.45
keysMethod · 0.45
valuesMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected