Skip to content

Commit 7d010b1

Browse files
Added test to cover usage from gh-998, and extended checks for
invalid/unsupported data types.
1 parent 1538b7d commit 7d010b1

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

dpctl/tests/test_usm_ndarray_ctor.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,23 @@ def test_dtypes(dtype):
9595
assert expected_fmt == actual_fmt
9696

9797

98-
@pytest.mark.parametrize("dtype", ["", ">f4", "invalid", 123])
98+
@pytest.mark.parametrize(
99+
"dtype",
100+
[
101+
"",
102+
">f4",
103+
"invalid",
104+
123,
105+
np.dtype(">f4"),
106+
np.dtype([("a", ">f4"), ("b", "i4")]),
107+
],
108+
)
99109
def test_dtypes_invalid(dtype):
100110
with pytest.raises((TypeError, ValueError)):
101111
dpt.usm_ndarray((1,), dtype=dtype)
102112

103113

104-
@pytest.mark.parametrize("dt", ["d", "c16"])
114+
@pytest.mark.parametrize("dt", ["f", "c8"])
105115
def test_properties(dt):
106116
"""
107117
Test that properties execute
@@ -1181,6 +1191,11 @@ def test_empty_like(dt, usm_kind):
11811191
assert X.sycl_queue == Y.sycl_queue
11821192

11831193

1194+
def test_empty_unexpected_data_type():
1195+
with pytest.raises(TypeError):
1196+
dpt.empty(1, dtype=np.object_)
1197+
1198+
11841199
@pytest.mark.parametrize(
11851200
"dt",
11861201
_all_dtypes,

0 commit comments

Comments
 (0)