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

Method test_abs

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

Source from the content-addressed store, hash-verified

777 self.assertNotEqual(hash(2000005 - 1j), -1)
778
779 def test_abs(self):
780 nums = [complex(x/3., y/7.) for x in range(-9,9) for y in range(-9,9)]
781 for num in nums:
782 self.assertAlmostEqual((num.real**2 + num.imag**2) ** 0.5, abs(num))
783
784 self.assertRaises(OverflowError, abs, complex(DBL_MAX, DBL_MAX))
785
786 def test_repr_str(self):
787 def test(v, expected, test_fn=self.assertEqual):

Callers

nothing calls this directly

Calls 3

assertAlmostEqualMethod · 0.95
absFunction · 0.85
assertRaisesMethod · 0.45

Tested by

no test coverage detected