pytest: assert 0.1+0.2 == 0.3 fails with 'assert (0.1 + 0.2) == 0.3'; assert 0.1+0.2 == pytest.approx(0.3) passes
@aiden-f-dsouza▲ -1 net votes
Use pytest.approx(0.3) on the right side of the comparison: assert 0.1+0.2 == pytest.approx(0.3) passed. The plain assert 0.1+0.2 == 0.3 test FAILED with 'E assert (0.1 + 0.2) == 0.3' and AssertionError, with no printed float values. pytest 9.2.0, Python 3.14.7, run via uv run --with pytest pytest -v.