diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2021-02-03 20:04:42 -0600 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2021-02-03 20:04:42 -0600 |
commit | 33953d21e735f9e31558a7c848970524ea9e2137 (patch) | |
tree | bc031e5a28b3c0f90d0db0c5d7f75fd465d9aaa2 /numpy | |
parent | 5bc12cd3243c805b05f0bb8d4e2ccf512bca1d38 (diff) | |
download | numpy-33953d21e735f9e31558a7c848970524ea9e2137.tar.gz |
TST: Split out failure test and ensure it requires cleanup
Adding the array is not sufficient to hit all code lines (although
most), because auxdata is NULL for most inputs.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_nditer.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py index 708241542..4271d2d96 100644 --- a/numpy/core/tests/test_nditer.py +++ b/numpy/core/tests/test_nditer.py @@ -1958,6 +1958,8 @@ def test_iter_buffered_cast_structured_type(): [np.array((1, 2, 3), dtype=sdt2), np.array((4, 5, 6), dtype=sdt2)]) + +def test_iter_buffered_cast_structured_type_failure_with_cleanup(): # make sure struct type -> struct type with different # number of fields fails sdt1 = [('a', 'f4'), ('b', 'i8'), ('d', 'O')] @@ -1967,12 +1969,13 @@ def test_iter_buffered_cast_structured_type(): for intent in ["readwrite", "readonly", "writeonly"]: # If the following assert fails, the place where the error is raised # within nditer may change. That is fine, but it may make sense for - # a new (hard to design) test to replace it: + # a new (hard to design) test to replace it. The `simple_arr` is + # designed to require a multi-step cast (due to having fields). assert np.can_cast(a.dtype, sdt2, casting="unsafe") - simple_arr = np.array([1, 2], dtype="i") # succeeds but needs clean up + simple_arr = np.array([1, 2], dtype="i,i") # requires clean up with pytest.raises(ValueError): nditer((simple_arr, a), ['buffered', 'refs_ok'], [intent, intent], - casting='unsafe', op_dtypes=["f", sdt2]) + casting='unsafe', op_dtypes=["f,f", sdt2]) def test_buffered_cast_error_paths(): |