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

Method assertAlmostEqual

Lib/test/test_complex.py:60–73  ·  view source on GitHub ↗
(self, a, b)

Source from the content-addressed store, hash-verified

58class ComplexTest(ComplexesAreIdenticalMixin, unittest.TestCase):
59
60 def assertAlmostEqual(self, a, b):
61 if isinstance(a, complex):
62 if isinstance(b, complex):
63 unittest.TestCase.assertAlmostEqual(self, a.real, b.real)
64 unittest.TestCase.assertAlmostEqual(self, a.imag, b.imag)
65 else:
66 unittest.TestCase.assertAlmostEqual(self, a.real, b)
67 unittest.TestCase.assertAlmostEqual(self, a.imag, 0.)
68 else:
69 if isinstance(b, complex):
70 unittest.TestCase.assertAlmostEqual(self, a, b.real)
71 unittest.TestCase.assertAlmostEqual(self, 0., b.imag)
72 else:
73 unittest.TestCase.assertAlmostEqual(self, a, b)
74
75 def assertClose(self, x, y, eps=1e-9):
76 """Return true iff complexes x and y "are close"."""

Callers 15

test_truedivMethod · 0.95
test_powMethod · 0.95
test_absMethod · 0.95
test_rate_limitMethod · 0.45
testConversionsMethod · 0.45
testArithmeticMethod · 0.45
testMixedPowerMethod · 0.45
testApproximatePiMethod · 0.45
testApproximateCos1Method · 0.45
test_switchintervalMethod · 0.45
test_one_insertMethod · 0.45
test_one_deleteMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected