You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pytest.approx Decimal repr omits or misstates the effective tolerance #15010
For Decimal values, pytest.approx can display the raw relative factor instead of the effective tolerance, ignore a larger absolute tolerance, or show ??? with valid defaults.
The comparison windows are [99, 101], [98, 102], and [99.9999, 100.0001]: both endpoints compare equal, while 101.1, 102.1, and 100.00011, respectively, compare unequal. The comparisons are correct in these examples; the display does not communicate their tolerance.
Expected: the values after ± should represent offsets of 1, 2, and 0.0001. The float equivalent already displays 100.0 ± 1 for pytest.approx(100.0, rel=0.01).
The existing test_decimal_approx_float_rel explicitly expects the raw relative factor. The cases above additionally demonstrate the omitted dominating absolute tolerance and unknown default. Related #13530/#13543 address a FloatOperation exception during repr.
Reproduced on pytest 9.1.1 and development commit 3fd8675d6d798507c06cf9c60753be6d9d7b0e17, with CPython 3.12.3 on Linux 6.8.0-100-generic x86-64.
Installed packages (uv pip list --offline; this environment has no pip module):
Activity
RonnyPfannschmidt commentedon Sep 13, 2026
Fixed by #15006
XerxesC-CN commentedon Oct 3, 2026
Hi, I'd like to work on this issue. Is it still available?