| 385 | 0 == approx(1, rel=-3) |
| 386 | |
| 387 | def test_inf_tolerance(self): |
| 388 | # Everything should be equal if the tolerance is infinite. |
| 389 | large_diffs = [(1, 1000), (1e-50, 1e50), (-1.0, -1e300), (0.0, 10)] |
| 390 | for a, x in large_diffs: |
| 391 | assert a != approx(x, rel=0.0, abs=0.0) |
| 392 | assert a == approx(x, rel=inf, abs=0.0) |
| 393 | assert a == approx(x, rel=0.0, abs=inf) |
| 394 | assert a == approx(x, rel=inf, abs=inf) |
| 395 | |
| 396 | def test_inf_tolerance_expecting_zero(self) -> None: |
| 397 | # If the relative tolerance is zero but the expected value is infinite, |