Minimal patch for compatibility with pytest 8

This commit is contained in:
Tomáš Hrnčiar
2024-04-18 12:01:23 +02:00
parent dade936c27
commit 0835a12374
2 changed files with 71 additions and 0 deletions
@@ -0,0 +1,67 @@
From 855ccd6448d06977f2911d9182d946e8206bae6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= <thrnciar@redhat.com>
Date: Thu, 18 Apr 2024 11:47:23 +0200
Subject: [PATCH] Minimal patch for compatibility with pytest 8
Inspired from upstream commit which does not apply to pint version we
have in Fedora
https://github.com/hgrecco/pint/commit/ba5fb6566dcefc1d7d34dfde48e498d69da05347
---
pint/quantity.py | 9 ++++-----
pint/testing.py | 8 ++++----
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/pint/quantity.py b/pint/quantity.py
index 1207b94..2cdb699 100644
--- a/pint/quantity.py
+++ b/pint/quantity.py
@@ -824,12 +824,11 @@ class Quantity(PrettyIPython, SharedRegistryObject, Generic[_MagnitudeType]):
"""
if not isinstance(self.magnitude, numbers.Number):
- msg = (
- "to_compact applied to non numerical types "
- "has an undefined behavior."
+ warnings.warn(
+ "to_compact applied to non numerical types has an undefined behavior.",
+ RuntimeWarning,
+ stacklevel=2,
)
- w = RuntimeWarning(msg)
- warnings.warn(w, stacklevel=2)
return self
if (
diff --git a/pint/testing.py b/pint/testing.py
index 3334675..485a29d 100644
--- a/pint/testing.py
+++ b/pint/testing.py
@@ -42,10 +42,10 @@ def assert_equal(first, second, msg=None):
if isinstance(m1, ndarray) or isinstance(m2, ndarray):
np.testing.assert_array_equal(m1, m2, err_msg=msg)
elif not isinstance(m1, Number):
- warnings.warn(RuntimeWarning)
+ warnings.warn("In assert_equal, m1 is not a number ", RuntimeWarning)
return
elif not isinstance(m2, Number):
- warnings.warn(RuntimeWarning)
+ warnings.warn("In assert_equal, m2 is not a number ", RuntimeWarning)
return
elif math.isnan(m1):
assert math.isnan(m2), msg
@@ -71,10 +71,10 @@ def assert_allclose(first, second, rtol=1e-07, atol=0, msg=None):
if isinstance(m1, ndarray) or isinstance(m2, ndarray):
np.testing.assert_allclose(m1, m2, rtol=rtol, atol=atol, err_msg=msg)
elif not isinstance(m1, Number):
- warnings.warn(RuntimeWarning)
+ warnings.warn("In assert_equal, m1 is not a number ", RuntimeWarning)
return
elif not isinstance(m2, Number):
- warnings.warn(RuntimeWarning)
+ warnings.warn("In assert_equal, m2 is not a number ", RuntimeWarning)
return
elif math.isnan(m1):
assert math.isnan(m2), msg
--
2.44.0
+4
View File
@@ -43,6 +43,10 @@ Patch: 0001-add-min-and-max-to-the-array-function-overrides.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2256746
Patch: 0001-Downstream-only-Backport-fix-for-importlib.resources.patch
# Compatibility with pytest 8
# https://github.com/hgrecco/pint/commit/ba5fb6566d.patch
Patch: 0001-Minimal-patch-for-compatibility-with-pytest-8.patch
BuildArch: noarch
%global _description %{expand: