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

Method test_richcompare

Lib/test/test_complex.py:219–245  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

217 a // b
218
219 def test_richcompare(self):
220 self.assertIs(complex.__eq__(1+1j, 1<<10000), False)
221 self.assertIs(complex.__lt__(1+1j, None), NotImplemented)
222 self.assertIs(complex.__eq__(1+1j, None), NotImplemented)
223 self.assertIs(complex.__eq__(1+1j, 1+1j), True)
224 self.assertIs(complex.__eq__(1+1j, 2+2j), False)
225 self.assertIs(complex.__ne__(1+1j, 1+1j), False)
226 self.assertIs(complex.__ne__(1+1j, 2+2j), True)
227 for i in range(1, 100):
228 f = i / 100.0
229 self.assertIs(complex.__eq__(f+0j, f), True)
230 self.assertIs(complex.__ne__(f+0j, f), False)
231 self.assertIs(complex.__eq__(complex(f, f), f), False)
232 self.assertIs(complex.__ne__(complex(f, f), f), True)
233 self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented)
234 self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented)
235 self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented)
236 self.assertIs(complex.__ge__(1+1j, 2+2j), NotImplemented)
237 self.assertRaises(TypeError, operator.lt, 1+1j, 2+2j)
238 self.assertRaises(TypeError, operator.le, 1+1j, 2+2j)
239 self.assertRaises(TypeError, operator.gt, 1+1j, 2+2j)
240 self.assertRaises(TypeError, operator.ge, 1+1j, 2+2j)
241 self.assertIs(operator.eq(1+1j, 1+1j), True)
242 self.assertIs(operator.eq(1+1j, 2+2j), False)
243 self.assertIs(operator.ne(1+1j, 1+1j), False)
244 self.assertIs(operator.ne(1+1j, 2+2j), True)
245 self.assertIs(operator.eq(1+1j, 2.0), False)
246
247 def test_richcompare_boundaries(self):
248 def check(n, deltas, is_equal, imag = 0.0):

Callers

nothing calls this directly

Calls 10

neMethod · 0.80
assertIsMethod · 0.45
__eq__Method · 0.45
__lt__Method · 0.45
__ne__Method · 0.45
__le__Method · 0.45
__gt__Method · 0.45
__ge__Method · 0.45
assertRaisesMethod · 0.45
eqMethod · 0.45

Tested by

no test coverage detected