| 2044 | |
| 2045 | |
| 2046 | def test_buffered_cast_error_paths(): |
| 2047 | with pytest.raises(ValueError): |
| 2048 | # The input is cast into an `S3` buffer |
| 2049 | np.nditer((np.array("a", dtype="S1"),), op_dtypes=["i"], |
| 2050 | casting="unsafe", flags=["buffered"]) |
| 2051 | |
| 2052 | # The `M8[ns]` is cast into the `S3` output |
| 2053 | it = np.nditer((np.array(1, dtype="i"),), op_dtypes=["S1"], |
| 2054 | op_flags=["writeonly"], casting="unsafe", flags=["buffered"]) |
| 2055 | with pytest.raises(ValueError): |
| 2056 | with it: |
| 2057 | buf = next(it) |
| 2058 | buf[...] = "a" # cannot be converted to int. |
| 2059 | |
| 2060 | @pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess") |
| 2061 | @pytest.mark.skipif(not HAS_REFCOUNT, reason="PyPy seems to not hit this.") |