From 2bd6677b5f8653aba0efad9bee1a0ca06dcabd04 Mon Sep 17 00:00:00 2001 From: Mamoru TASAKA Date: Tue, 18 Jul 2023 00:23:25 +0900 Subject: [PATCH] fix: support pytest on python 3.12 wrt Fraction formatting change python 3.12 supports float-style formatting for Fraction by https://github.com/python/cpython/pull/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 . --- pint/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pint/testing.py b/pint/testing.py index 126a39fc8..f2a570a59 100644 --- a/pint/testing.py +++ b/pint/testing.py @@ -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: