Skip to content

Commit 6334991

Browse files
committed
Add more tests to cover new dpnp.memory.create_data function
1 parent 3a729ac commit 6334991

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

dpnp/tests/test_memory.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import dpctl.tensor as dpt
2+
import numpy
3+
import pytest
4+
5+
import dpnp
6+
import dpnp.memory as dpm
7+
8+
9+
class IntUsmData(dpt.usm_ndarray):
10+
"""Class that overrides `usm_data` property in `dpt.usm_ndarray`."""
11+
12+
@property
13+
def usm_data(self):
14+
return 1
15+
16+
17+
class TestCreateData:
18+
@pytest.mark.parametrize("x", [numpy.ones(4), dpnp.zeros(2)])
19+
def test_wrong_input_type(self, x):
20+
with pytest.raises(TypeError):
21+
dpm.create_data(x)
22+
23+
def test_wrong_usm_data(self):
24+
a = dpt.ones(10)
25+
d = IntUsmData(a.shape, buffer=a)
26+
27+
with pytest.raises(TypeError):
28+
dpm.create_data(d)

0 commit comments

Comments
 (0)