mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Oops! 2.6's Rational.__ne__ didn't work.
This commit is contained in:
parent
b01aa430d5
commit
27d339446a
2 changed files with 6 additions and 1 deletions
|
@ -174,7 +174,10 @@ class Complex(Number):
|
||||||
"""self == other"""
|
"""self == other"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
# __ne__ is inherited from object and negates whatever __eq__ does.
|
def __ne__(self, other):
|
||||||
|
"""self != other"""
|
||||||
|
# The default __ne__ doesn't negate __eq__ until 3.0.
|
||||||
|
return not (self == other)
|
||||||
|
|
||||||
Complex.register(complex)
|
Complex.register(complex)
|
||||||
|
|
||||||
|
|
|
@ -313,6 +313,8 @@ class RationalTest(unittest.TestCase):
|
||||||
self.assertFalse(R(2, 3) <= R(1, 2))
|
self.assertFalse(R(2, 3) <= R(1, 2))
|
||||||
self.assertTrue(R(1, 2) == R(1, 2))
|
self.assertTrue(R(1, 2) == R(1, 2))
|
||||||
self.assertFalse(R(1, 2) == R(1, 3))
|
self.assertFalse(R(1, 2) == R(1, 3))
|
||||||
|
self.assertFalse(R(1, 2) != R(1, 2))
|
||||||
|
self.assertTrue(R(1, 2) != R(1, 3))
|
||||||
|
|
||||||
def testMixedLess(self):
|
def testMixedLess(self):
|
||||||
self.assertTrue(2 < R(5, 2))
|
self.assertTrue(2 < R(5, 2))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue