diff options
author | Tyler Reddy <tyler.je.reddy@gmail.com> | 2018-08-01 17:27:32 -0700 |
---|---|---|
committer | Tyler Reddy <tyler.je.reddy@gmail.com> | 2018-08-01 17:27:32 -0700 |
commit | 81bd37e73b854974312a971d0742793caf425684 (patch) | |
tree | 9bc7723a70863c52cbeec51d7cf5f4f0bf11ee7b /numpy/lib/tests/test_stride_tricks.py | |
parent | 6105281cf245c5713660245a0c87ae00e85aec23 (diff) | |
download | numpy-81bd37e73b854974312a971d0742793caf425684.tar.gz |
TST: add broadcast_arrays() kwarg unit test for TypeError
* broadcast_arrays() is now tested for the case when an invalid
keyword argument is used; the appropriate error string content
is also tested for
* the TypeError message produced in the above case has been restored
to the correct value in Python 3
Diffstat (limited to 'numpy/lib/tests/test_stride_tricks.py')
-rw-r--r-- | numpy/lib/tests/test_stride_tricks.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_stride_tricks.py b/numpy/lib/tests/test_stride_tricks.py index 3c2ca8b87..c6e944847 100644 --- a/numpy/lib/tests/test_stride_tricks.py +++ b/numpy/lib/tests/test_stride_tricks.py @@ -3,7 +3,8 @@ from __future__ import division, absolute_import, print_function import numpy as np from numpy.core._rational_tests import rational from numpy.testing import ( - assert_equal, assert_array_equal, assert_raises, assert_ + assert_equal, assert_array_equal, assert_raises, assert_, + assert_raises_regex ) from numpy.lib.stride_tricks import ( as_strided, broadcast_arrays, _broadcast_shape, broadcast_to @@ -57,6 +58,17 @@ def test_same(): assert_array_equal(x, bx) assert_array_equal(y, by) +def test_broadcast_kwargs(): + # ensure that a TypeError is appropriately raised when + # np.broadcast_arrays() is called with any keyword + # argument other than 'subok' + x = np.arange(10) + y = np.arange(10) + + with assert_raises_regex(TypeError, + 'broadcast_arrays\\(\\) got an unexpected keyword*'): + broadcast_arrays(x, y, dtype='float64') + def test_one_off(): x = np.array([[1, 2, 3]]) |