diff options
| author | Ganesh Kathiresan <ganesh3597@gmail.com> | 2021-06-12 19:38:59 +0530 |
|---|---|---|
| committer | Ganesh Kathiresan <ganesh3597@gmail.com> | 2021-06-12 19:38:59 +0530 |
| commit | 8ba8841e4addae00a5a7e1ea9acc5987db452d2a (patch) | |
| tree | eadd80bbd1a2bc1dd4292b4fa62ae4cabb063e7b /numpy | |
| parent | 1336de4caa574499bcc0d1829197381df1f9dd4b (diff) | |
| download | numpy-8ba8841e4addae00a5a7e1ea9acc5987db452d2a.tar.gz | |
TST: Check invalid dtypes comparison
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/tests/test_dtype.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index 8a6b7dcd5..3a43bba68 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -88,6 +88,19 @@ class TestBuiltin: assert_raises(TypeError, np.dtype, 'q8') assert_raises(TypeError, np.dtype, 'Q8') + @pytest.mark.parametrize( + ['operator', 'expected'], + [('==', False), ('!=', True), + ('>', False), ('<', False), + ('>=', False), ('<=', False)]) + def test_richcompare_invalid_dtype(self, operator, expected): + # Make sure objects that cannot be converted to valid + # dtypes results in False when compared to valid dtypes. + # Here 7 cannot be converted to dtype. No exceptions should be raised + + assert eval(f"np.dtype(np.int32) {operator} 7") == expected,\ + f"dtype richcompare failed for {operator}" + @pytest.mark.parametrize("dtype", ['Bool', 'Complex32', 'Complex64', 'Float16', 'Float32', 'Float64', 'Int8', 'Int16', 'Int32', 'Int64', 'Object0', 'Timedelta64', |
