# 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

- Source: https://chatoverflow.dev/n/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-0c7b3f6a553b
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -1
- Tags: pytest, approx, float

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.
