summaryrefslogtreecommitdiff
blob: cd829c5ef08eee197b21d30f60571eb79a8786d4 (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
https://github.com/numpy/numpy/commit/515403f2c637cb58f8dc326d88dd6f768f027cf4
https://github.com/numpy/numpy/commit/b0872b858e2e6ebc394e95c81a024dcf1573c690
https://github.com/numpy/numpy/commit/e42fc93b54a6d41dab72d86921f96e5ebc4c4198
https://github.com/numpy/numpy/commit/4552b6cb0083502f731794e961cd30b9b62ba2e3

From 515403f2c637cb58f8dc326d88dd6f768f027cf4 Mon Sep 17 00:00:00 2001
From: Ralf Gommers <ralf.gommers@gmail.com>
Date: Sun, 18 Jun 2023 15:56:23 +0200
Subject: [PATCH] TST: disable `test_new_policy` test for memory allocator.

This is way too slow, running a large part of the test suite twice.
Issue 23975 tracks changing how this feature is tested.
---
 numpy/core/tests/test_mem_policy.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/numpy/core/tests/test_mem_policy.py b/numpy/core/tests/test_mem_policy.py
index b4e2f65916c..0855d60771a 100644
--- a/numpy/core/tests/test_mem_policy.py
+++ b/numpy/core/tests/test_mem_policy.py
@@ -359,7 +359,7 @@ def test_thread_locality(get_module):
     assert np.core.multiarray.get_handler_name() == orig_policy_name
 
 
-@pytest.mark.slow
+@pytest.mark.skip(reason="too slow, see gh-23975")
 def test_new_policy(get_module):
     a = np.arange(10)
     orig_policy_name = np.core.multiarray.get_handler_name(a)

From b0872b858e2e6ebc394e95c81a024dcf1573c690 Mon Sep 17 00:00:00 2001
From: Ralf Gommers <ralf.gommers@gmail.com>
Date: Mon, 19 Jun 2023 11:07:19 +0200
Subject: [PATCH] TST: skip refcount related tests on py312

Python 3.12 has immortal refcounts; the initial and final
values will be the same when accessing `sys.getrefcount` inside a
test.

Closes gh-23986
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -755,6 +755,11 @@ def iter_struct_object_dtypes():
     yield pytest.param(dt, p, 12, obj, id="<structured subarray 2>")
 
 
+@pytest.mark.skipif(
+    sys.version_info >= (3, 12),
+    reason="Python 3.12 has immortal refcounts, this test will no longer "
+           "work. See gh-23986"
+)
 @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
 class TestStructuredObjectRefcounting:
     """These tests cover various uses of complicated structured types which
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -1465,6 +1465,10 @@ def test_structured_arrays_with_objects1(self):
         x[x.nonzero()] = x.ravel()[:1]
         assert_(x[0, 1] == x[0, 0])
 
+    @pytest.mark.skipif(
+        sys.version_info >= (3, 12),
+        reason="Python 3.12 has immortal refcounts, this test no longer works."
+    )
     @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
     def test_structured_arrays_with_objects2(self):
         # Ticket #1299 second test

From e42fc93b54a6d41dab72d86921f96e5ebc4c4198 Mon Sep 17 00:00:00 2001
From: Ralf Gommers <ralf.gommers@gmail.com>
Date: Mon, 19 Jun 2023 11:14:38 +0200
Subject: [PATCH] TST: skip memory allocator and `array_interface` tests on
 py312

They require numpy.distutils, which isn't available on >=3.12
The `numpy.testing.extbuild` utility will need changing to make this
work again. Could either use plain `setuptools` or `meson`.
--- a/numpy/core/tests/test_array_interface.py
+++ b/numpy/core/tests/test_array_interface.py
@@ -128,6 +128,9 @@ def get_module(tmp_path):
                                                more_init=more_init)
 
 
+# FIXME: numpy.testing.extbuild uses `numpy.distutils`, so this won't work on
+# Python 3.12 and up.
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
 @pytest.mark.slow
 def test_cstruct(get_module):
 
--- a/numpy/core/tests/test_mem_policy.py
+++ b/numpy/core/tests/test_mem_policy.py
@@ -9,6 +9,11 @@
 import sys
 
 
+# FIXME: numpy.testing.extbuild uses `numpy.distutils`, so this won't work on
+# Python 3.12 and up. It's an internal test utility, so for now we just skip
+# these tests.
+
+
 @pytest.fixture
 def get_module(tmp_path):
     """ Add a memory policy that returns a false pointer 64 bytes into the
@@ -213,6 +218,7 @@ def get_module(tmp_path):
                                                more_init=more_init)
 
 
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
 def test_set_policy(get_module):
 
     get_handler_name = np.core.multiarray.get_handler_name
@@ -241,6 +247,7 @@ def test_set_policy(get_module):
         assert get_handler_name() == orig_policy_name
 
 
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
 def test_default_policy_singleton(get_module):
     get_handler_name = np.core.multiarray.get_handler_name
 
@@ -262,6 +269,7 @@ def test_default_policy_singleton(get_module):
     assert def_policy_1 is def_policy_2 is get_module.get_default_policy()
 
 
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
 def test_policy_propagation(get_module):
     # The memory policy goes hand-in-hand with flags.owndata
 
@@ -320,6 +328,7 @@ async def async_test_context_locality(get_module):
     assert np.core.multiarray.get_handler_name() == orig_policy_name
 
 
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
 def test_context_locality(get_module):
     if (sys.implementation.name == 'pypy'
             and sys.pypy_version_info[:3] < (7, 3, 6)):
@@ -341,6 +350,7 @@ def concurrent_thread2(get_module, event):
     get_module.set_secret_data_policy()
 
 
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
 def test_thread_locality(get_module):
     orig_policy_name = np.core.multiarray.get_handler_name()
 
@@ -359,6 +369,7 @@ def test_thread_locality(get_module):
     assert np.core.multiarray.get_handler_name() == orig_policy_name
 
 
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
 @pytest.mark.skip(reason="too slow, see gh-23975")
 def test_new_policy(get_module):
     a = np.arange(10)
@@ -388,6 +399,8 @@ def test_new_policy(get_module):
     c = np.arange(10)
     assert np.core.multiarray.get_handler_name(c) == orig_policy_name
 
+
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
 @pytest.mark.xfail(sys.implementation.name == "pypy",
                    reason=("bad interaction between getenv and "
                            "os.environ inside pytest"))
@@ -420,6 +433,8 @@ def test_switch_owner(get_module, policy):
         else:
             os.environ['NUMPY_WARN_IF_NO_MEM_POLICY'] = oldval
 
+
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="no numpy.distutils")
 def test_owner_is_base(get_module):
     a = get_module.get_array_with_base()
     with pytest.warns(UserWarning, match='warn_on_free'):


From 4552b6cb0083502f731794e961cd30b9b62ba2e3 Mon Sep 17 00:00:00 2001
From: Ralf Gommers <ralf.gommers@gmail.com>
Date: Mon, 19 Jun 2023 12:07:32 +0200
Subject: [PATCH] TST: skip test using `np.load` on py2-saved .npy file on
 py312

--- a/numpy/lib/tests/test_format.py
+++ b/numpy/lib/tests/test_format.py
@@ -527,6 +527,7 @@ def test_load_padded_dtype(tmpdir, dt):
     assert_array_equal(arr, arr1)
 
 
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason="see gh-23988")
 @pytest.mark.xfail(IS_WASM, reason="Emscripten NODEFS has a buggy dup")
 def test_python2_python3_interoperability():
     fname = 'win64python2.npy'