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

Method test_numbers

Lib/test/test_compare.py:407–441  ·  view source on GitHub ↗

Compare number types.

(self)

Source from the content-addressed store, hash-verified

405 self.assert_total_order(c2, s2, 0)
406
407 def test_numbers(self):
408 """Compare number types."""
409
410 # Same types.
411 i1 = 1001
412 i2 = 1002
413 self.assert_total_order(i1, i1, 0)
414 self.assert_total_order(i1, i2, -1)
415
416 f1 = 1001.0
417 f2 = 1001.1
418 self.assert_total_order(f1, f1, 0)
419 self.assert_total_order(f1, f2, -1)
420
421 q1 = Fraction(2002, 2)
422 q2 = Fraction(2003, 2)
423 self.assert_total_order(q1, q1, 0)
424 self.assert_total_order(q1, q2, -1)
425
426 d1 = Decimal('1001.0')
427 d2 = Decimal('1001.1')
428 self.assert_total_order(d1, d1, 0)
429 self.assert_total_order(d1, d2, -1)
430
431 c1 = 1001+0j
432 c2 = 1001+1j
433 self.assert_equality_only(c1, c1, True)
434 self.assert_equality_only(c1, c2, False)
435
436
437 # Mixing types.
438 for n1, n2 in ((i1,f1), (i1,q1), (i1,d1), (f1,q1), (f1,d1), (q1,d1)):
439 self.assert_total_order(n1, n2, 0)
440 for n1 in (i1, f1, q1, d1):
441 self.assert_equality_only(n1, c1, True)
442
443 def test_sequences(self):
444 """Compare list, tuple, and range."""

Callers

nothing calls this directly

Calls 4

assert_total_orderMethod · 0.95
assert_equality_onlyMethod · 0.95
FractionClass · 0.90
DecimalClass · 0.90

Tested by

no test coverage detected