Skip to content

Commit dc7aa6c

Browse files
Added arg validation tests for some constructors
1 parent 6f6916e commit dc7aa6c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

dpctl/tests/test_usm_ndarray_ctor.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,3 +1129,35 @@ def test_full_like(dt, usm_kind):
11291129
assert X.usm_type == Y.usm_type
11301130
assert X.sycl_queue == Y.sycl_queue
11311131
assert np.array_equal(dpt.asnumpy(Y), np.ones(X.shape, dtype=X.dtype))
1132+
1133+
1134+
def test_common_arg_validation():
1135+
order = "I"
1136+
# invalid order must raise ValueError
1137+
with pytest.raises(ValueError):
1138+
dpt.empty(10, order=order)
1139+
with pytest.raises(ValueError):
1140+
dpt.zeros(10, order=order)
1141+
with pytest.raises(ValueError):
1142+
dpt.ones(10, order=order)
1143+
with pytest.raises(ValueError):
1144+
dpt.full(10, 1, order=order)
1145+
X = dpt.empty(10)
1146+
with pytest.raises(ValueError):
1147+
dpt.empty_like(X, order=order)
1148+
with pytest.raises(ValueError):
1149+
dpt.zeros_like(X, order=order)
1150+
with pytest.raises(ValueError):
1151+
dpt.ones_like(X, order=order)
1152+
with pytest.raises(ValueError):
1153+
dpt.full_like(X, 1, order=order)
1154+
X = dict()
1155+
# test for type validation
1156+
with pytest.raises(TypeError):
1157+
dpt.empty_like(X)
1158+
with pytest.raises(TypeError):
1159+
dpt.zeros_like(X)
1160+
with pytest.raises(TypeError):
1161+
dpt.ones_like(X)
1162+
with pytest.raises(TypeError):
1163+
dpt.full_like(X, 1)

0 commit comments

Comments
 (0)