File: Fix-test-to-match-python-3.14.patch

package info (click to toggle)
skimage 0.25.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,720 kB
  • sloc: python: 60,007; cpp: 2,592; ansic: 1,591; xml: 1,342; javascript: 1,267; makefile: 168; sh: 20
file content (89 lines) | stat: -rw-r--r-- 3,721 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From: Grzegorz Bokota <bokota+github@gmail.com>
Date: Fri, 22 Aug 2025 10:19:26 +0200
Subject: Fix test to match python 3.14

Extracted from #7877

Origin: upstream, https://github.com/scikit-image/scikit-image/commit/61b32225cc75fc94d8b056dc6780cb1bf4cdcadf#diff-b18ac9fbca7548d3f9279dccca614307ec05194648515f467ac1e139b32adadd
Closes: #1118742
---
 skimage/_shared/tests/test_utils.py |  4 ++--
 skimage/_shared/utils.py            | 23 +++++++++++++----------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/skimage/_shared/tests/test_utils.py b/skimage/_shared/tests/test_utils.py
index a1e21e3..60a7e17 100644
--- a/skimage/_shared/tests/test_utils.py
+++ b/skimage/_shared/tests/test_utils.py
@@ -470,13 +470,13 @@ class Test_deprecate_parameter:
                 _func_deprecated_params(1, 2, old0=2)
 
     def test_wrong_param_name(self):
-        with pytest.raises(ValueError, match="'old' is not in list"):
+        with pytest.raises(ValueError, match="'old' not in parameters"):
 
             @deprecate_parameter("old", start_version="0.10", stop_version="0.12")
             def foo(arg0):
                 pass
 
-        with pytest.raises(ValueError, match="'new' is not in list"):
+        with pytest.raises(ValueError, match="'new' not in parameters"):
 
             @deprecate_parameter(
                 "old", new_name="new", start_version="0.10", stop_version="0.12"
diff --git a/skimage/_shared/utils.py b/skimage/_shared/utils.py
index a793509..ee28a8d 100644
--- a/skimage/_shared/utils.py
+++ b/skimage/_shared/utils.py
@@ -252,11 +252,17 @@ class deprecate_parameter:
 
     def __call__(self, func):
         parameters = inspect.signature(func).parameters
-        deprecated_idx = list(parameters.keys()).index(self.deprecated_name)
+        try:
+            deprecated_idx = list(parameters.keys()).index(self.deprecated_name)
+        except ValueError as e:
+            raise ValueError(f"{self.deprecated_name!r} not in parameters") from e
+
+        new_idx = False
         if self.new_name:
-            new_idx = list(parameters.keys()).index(self.new_name)
-        else:
-            new_idx = False
+            try:
+                new_idx = list(parameters.keys()).index(self.new_name)
+            except ValueError as e:
+                raise ValueError(f"{self.new_name!r} not in parameters") from e
 
         if parameters[self.deprecated_name].default is not DEPRECATED:
             raise RuntimeError(
@@ -520,8 +526,7 @@ class deprecate_func(_DecoratorBaseClass):
 
     def __call__(self, func):
         message = (
-            f"`{func.__name__}` is deprecated since version "
-            f"{self.deprecated_version}"
+            f"`{func.__name__}` is deprecated since version {self.deprecated_version}"
         )
         if self.removed_version:
             message += f" and will be removed in version {self.removed_version}."
@@ -613,9 +618,7 @@ def safe_as_int(val, atol=1e-3):
     try:
         np.testing.assert_allclose(mod, 0, atol=atol)
     except AssertionError:
-        raise ValueError(
-            f'Integer argument required but received ' f'{val}, check inputs.'
-        )
+        raise ValueError(f'Integer argument required but received {val}, check inputs.')
 
     return np.round(val).astype(np.int64)
 
@@ -776,7 +779,7 @@ def _validate_interpolation_order(image_dtype, order):
         return 0 if image_dtype == bool else 1
 
     if order < 0 or order > 5:
-        raise ValueError("Spline interpolation order has to be in the " "range 0-5.")
+        raise ValueError("Spline interpolation order has to be in the range 0-5.")
 
     if image_dtype == bool and order != 0:
         raise ValueError(