Skip to content

Commit ad5610f

Browse files
Added test that readonly out raises
1 parent 8aa3dc9 commit ad5610f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

dpctl/tests/elementwise/test_elementwise_classes.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
import pytest
18+
1719
import dpctl.tensor as dpt
1820
from dpctl.tests.helper import get_queue_or_skip
1921

@@ -49,6 +51,15 @@ def test_unary_class_str_repr():
4951
assert kl_n in r
5052

5153

54+
def test_unary_read_only_out():
55+
get_queue_or_skip()
56+
x = dpt.arange(32, dtype=dpt.int32)
57+
r = dpt.empty_like(x)
58+
r.flags["W"] = False
59+
with pytest.raises(ValueError):
60+
unary_fn(x, out=r)
61+
62+
5263
def test_binary_class_getters():
5364
fn = binary_fn.get_implementation_function()
5465
assert callable(fn)
@@ -105,3 +116,13 @@ def test_binary_class_nout():
105116
nout = binary_fn.nout
106117
assert isinstance(nout, int)
107118
assert nout == 1
119+
120+
121+
def test_biary_read_only_out():
122+
get_queue_or_skip()
123+
x1 = dpt.ones(32, dtype=dpt.float32)
124+
x2 = dpt.ones_like(x1)
125+
r = dpt.empty_like(x1)
126+
r.flags["W"] = False
127+
with pytest.raises(ValueError):
128+
binary_fn(x1, x2, out=r)

0 commit comments

Comments
 (0)