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

Method test_comp_classes_same

Lib/test/test_compare.py:342–365  ·  view source on GitHub ↗

Compare same-class instances with comparison methods.

(self)

Source from the content-addressed store, hash-verified

340 self.assert_equality_only(a, b, False)
341
342 def test_comp_classes_same(self):
343 """Compare same-class instances with comparison methods."""
344
345 for cls in self.all_comp_classes:
346 with self.subTest(cls):
347 instances = self.create_sorted_instances(cls, (1, 2, 1))
348
349 # Same object.
350 self.assert_total_order(instances[0], instances[0], 0,
351 cls.meth, cls.meth)
352
353 # Different objects, same value.
354 self.assert_total_order(instances[0], instances[2], 0,
355 cls.meth, cls.meth)
356
357 # Different objects, value ascending for ascending identities.
358 self.assert_total_order(instances[0], instances[1], -1,
359 cls.meth, cls.meth)
360
361 # different objects, value descending for ascending identities.
362 # This is the interesting case to assert that order comparison
363 # is performed based on the value and not based on the identity.
364 self.assert_total_order(instances[1], instances[2], +1,
365 cls.meth, cls.meth)
366
367 def test_comp_classes_different(self):
368 """Compare different-class instances with comparison methods."""

Callers

nothing calls this directly

Calls 3

assert_total_orderMethod · 0.95
subTestMethod · 0.45

Tested by

no test coverage detected