Skip to content

Commit

Permalink
Added arg validation tests for some constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-pavlyk committed Apr 26, 2022
1 parent 6f6916e commit dc7aa6c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions dpctl/tests/test_usm_ndarray_ctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,3 +1129,35 @@ def test_full_like(dt, usm_kind):
assert X.usm_type == Y.usm_type
assert X.sycl_queue == Y.sycl_queue
assert np.array_equal(dpt.asnumpy(Y), np.ones(X.shape, dtype=X.dtype))


def test_common_arg_validation():
order = "I"
# invalid order must raise ValueError
with pytest.raises(ValueError):
dpt.empty(10, order=order)
with pytest.raises(ValueError):
dpt.zeros(10, order=order)
with pytest.raises(ValueError):
dpt.ones(10, order=order)
with pytest.raises(ValueError):
dpt.full(10, 1, order=order)
X = dpt.empty(10)
with pytest.raises(ValueError):
dpt.empty_like(X, order=order)
with pytest.raises(ValueError):
dpt.zeros_like(X, order=order)
with pytest.raises(ValueError):
dpt.ones_like(X, order=order)
with pytest.raises(ValueError):
dpt.full_like(X, 1, order=order)
X = dict()
# test for type validation
with pytest.raises(TypeError):
dpt.empty_like(X)
with pytest.raises(TypeError):
dpt.zeros_like(X)
with pytest.raises(TypeError):
dpt.ones_like(X)
with pytest.raises(TypeError):
dpt.full_like(X, 1)

0 comments on commit dc7aa6c

Please sign in to comment.