Skip to content

Commit 2b17c13

Browse files
committed
TST: account for immortal objects in test_iter_refcount
1 parent ffb23cd commit 2b17c13

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

numpy/_core/tests/test_nditer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import sysconfig
23
import pytest
34

45
import textwrap
@@ -13,6 +14,7 @@
1314
IS_WASM, HAS_REFCOUNT, suppress_warnings, break_cycles
1415
)
1516

17+
NOGIL_BUILD = bool(sysconfig.get_config_var('Py_GIL_DISABLED'))
1618

1719
def iter_multi_index(i):
1820
ret = []
@@ -68,7 +70,9 @@ def test_iter_refcount():
6870
rc2_dt = sys.getrefcount(dt)
6971
it2 = it.copy()
7072
assert_(sys.getrefcount(a) > rc2_a)
71-
assert_(sys.getrefcount(dt) > rc2_dt)
73+
if not NOGIL_BUILD:
74+
# np.dtype('f4') is immortal in the nogil build
75+
assert_(sys.getrefcount(dt) > rc2_dt)
7276
it = None
7377
assert_equal(sys.getrefcount(a), rc2_a)
7478
assert_equal(sys.getrefcount(dt), rc2_dt)

0 commit comments

Comments
 (0)