Skip to content

Commit

Permalink
fix: support pytest on python 3.12 wrt Fraction formatting change
Browse files Browse the repository at this point in the history
python 3.12 supports float-style formatting for Fraction by
python/cpython#100161 .
With this change, when ":n" format specifier is used in format() for
Fraction type, this now raises ValueError instead of previous
TypeError.

To make pytest succeed with python 3.12, make
pint.testing.assert_allclose also rescue ValueError .

Fixes #1818 .
  • Loading branch information
mtasaka committed Jul 17, 2023
1 parent 4cca8ab commit 2bd6677
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pint/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def assert_allclose(
if msg is None:
try:
msg = f"Comparing {first!r} and {second!r}. "
except TypeError:
except (TypeError, ValueError):
try:
msg = f"Comparing {first} and {second}. "
except Exception:
Expand Down

0 comments on commit 2bd6677

Please sign in to comment.