MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_custom_tolerances

Method test_custom_tolerances

testing/python/approx.py:436–450  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

434 assert op(a, approx(x))
435
436 def test_custom_tolerances(self):
437 assert 1e8 + 1e0 == approx(1e8, rel=5e-8, abs=5e0)
438 assert 1e8 + 1e0 == approx(1e8, rel=5e-9, abs=5e0)
439 assert 1e8 + 1e0 == approx(1e8, rel=5e-8, abs=5e-1)
440 assert 1e8 + 1e0 != approx(1e8, rel=5e-9, abs=5e-1)
441
442 assert 1e0 + 1e-8 == approx(1e0, rel=5e-8, abs=5e-8)
443 assert 1e0 + 1e-8 == approx(1e0, rel=5e-9, abs=5e-8)
444 assert 1e0 + 1e-8 == approx(1e0, rel=5e-8, abs=5e-9)
445 assert 1e0 + 1e-8 != approx(1e0, rel=5e-9, abs=5e-9)
446
447 assert 1e-8 + 1e-16 == approx(1e-8, rel=5e-8, abs=5e-16)
448 assert 1e-8 + 1e-16 == approx(1e-8, rel=5e-9, abs=5e-16)
449 assert 1e-8 + 1e-16 == approx(1e-8, rel=5e-8, abs=5e-17)
450 assert 1e-8 + 1e-16 != approx(1e-8, rel=5e-9, abs=5e-17)
451
452 def test_relative_tolerance(self):
453 within_1e8_rel = [(1e8 + 1e0, 1e8), (1e0 + 1e-8, 1e0), (1e-8 + 1e-16, 1e-8)]

Callers

nothing calls this directly

Calls 1

approxFunction · 0.90

Tested by

no test coverage detected