summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-04-12 01:40:54 -0700
committerEric Wieser <wieser.eric@gmail.com>2018-04-20 00:17:16 -0700
commit63e9cfbebf8ed00514c1adebb03ddfc455369394 (patch)
treebcd192e9496f54dea090b14e124e51ebdfdf64ba
parent056babb57ad8e800d3819484f8c6da9b0c3948d5 (diff)
downloadnumpy-63e9cfbebf8ed00514c1adebb03ddfc455369394.tar.gz
TST: Work around memory leak in ctypes to prevent another test failing
-rw-r--r--numpy/core/tests/test_multiarray.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 21c036629..c7f110828 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -6522,12 +6522,20 @@ class TestNewBufferProtocol(object):
a = np.empty((1,) * 32)
self._check_roundtrip(a)
+ def _make_ctype(shape, scalar_type):
+ t = scalar_type
+ for dim in shape[::-1]:
+ t = dim * t
+ return t
+
+ # This creates deeply nested reference cycles that cause
+ # np.lib.tests.test_io.test_load_refcount to erroneously fail (gh-10891).
+ # Not making it a local ensure that the GC doesn't touch it during the tests
+ c_u8_33d = _make_ctype((1,)*33, ctypes.c_uint8)
+
def test_error_too_many_dims(self):
# construct a memoryview with 33 dimensions
- ct = ctypes.c_uint8
- for i in range(33):
- ct = 1 * ct
- m = memoryview(ct())
+ m = memoryview(self.c_u8_33d())
assert_equal(m.ndim, 33)
assert_raises_regex(