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

Method test_ne_low_priority

Lib/test/test_compare.py:72–88  ·  view source on GitHub ↗

object.__ne__() should not invoke reflected __eq__()

(self)

Source from the content-addressed store, hash-verified

70 self.assertSequenceEqual(calls, ['Left.__eq__', 'Right.__ne__'])
71
72 def test_ne_low_priority(self):
73 """object.__ne__() should not invoke reflected __eq__()"""
74 calls = []
75 class Base:
76 # Inherits object.__ne__()
77 def __eq__(*args):
78 calls.append('Base.__eq__')
79 return NotImplemented
80 class Derived(Base): # Subclassing forces higher priority
81 def __eq__(*args):
82 calls.append('Derived.__eq__')
83 return NotImplemented
84 def __ne__(*args):
85 calls.append('Derived.__ne__')
86 return NotImplemented
87 Base() != Derived()
88 self.assertSequenceEqual(calls, ['Derived.__ne__', 'Base.__eq__'])
89
90 def test_other_delegation(self):
91 """No default delegation between operations except __ne__()"""

Callers

nothing calls this directly

Calls 3

assertSequenceEqualMethod · 0.80
BaseClass · 0.70
DerivedClass · 0.70

Tested by

no test coverage detected