Skip to content

Commit 2bd6677

Browse files
committed
fix: support pytest on python 3.12 wrt Fraction formatting change
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 hgrecco#1818 .
1 parent 4cca8ab commit 2bd6677

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pint/testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def assert_allclose(
6464
if msg is None:
6565
try:
6666
msg = f"Comparing {first!r} and {second!r}. "
67-
except TypeError:
67+
except (TypeError, ValueError):
6868
try:
6969
msg = f"Comparing {first} and {second}. "
7070
except Exception:

0 commit comments

Comments
 (0)