Skip to content

Commit 1ee8e19

Browse files
committed
Add tests for positional-only keywords in astype
1 parent 89668ff commit 1ee8e19

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

dpnp/tests/test_arraycreation.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
assert_array_equal,
1111
assert_equal,
1212
assert_raises,
13+
assert_raises_regex,
1314
)
1415

1516
import dpnp
@@ -57,6 +58,28 @@ def test_error(self):
5758
assert_raises(TypeError, dpnp.array, x, ndmin=3.0)
5859

5960

61+
class TestAsType:
62+
@testing.with_requires("numpy>=2.0")
63+
@pytest.mark.parametrize("xp", [dpnp, numpy])
64+
def test_validate_positional_args(self, xp):
65+
x = xp.ones(4)
66+
assert_raises_regex(
67+
TypeError,
68+
"got some positional-only arguments passed as keyword arguments",
69+
xp.astype,
70+
x,
71+
dtype="f4",
72+
)
73+
assert_raises_regex(
74+
TypeError,
75+
"takes 2 positional arguments but 3 were given",
76+
xp.astype,
77+
x,
78+
"f4",
79+
None,
80+
)
81+
82+
6083
class TestTrace:
6184
@pytest.mark.parametrize("a_sh", [(3, 4), (2, 2, 2)])
6285
@pytest.mark.parametrize(

dpnp/tests/test_ndarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_basic(self, arr, arr_dtype, res_dtype):
3838
assert_allclose(expected, result)
3939

4040
def test_subok_error(self):
41-
x = dpnp.ones((4))
41+
x = dpnp.ones(4)
4242
with pytest.raises(NotImplementedError):
4343
x.astype("i4", subok=False)
4444

0 commit comments

Comments
 (0)