From 5b64ee617248ef67b138223d8b2b2bd69ef6d782 Mon Sep 17 00:00:00 2001 From: Anastasia Kuporosova Date: Wed, 13 Nov 2024 11:26:21 +0000 Subject: [PATCH] add test --- src/bindings/python/tests/test_graph/test_constant.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bindings/python/tests/test_graph/test_constant.py b/src/bindings/python/tests/test_graph/test_constant.py index 0c6f98559be496..effd351a54c2fc 100644 --- a/src/bindings/python/tests/test_graph/test_constant.py +++ b/src/bindings/python/tests/test_graph/test_constant.py @@ -205,6 +205,15 @@ def test_init_with_scalar(init_value, src_dtype, dst_dtype, shared_flag, data_ge assert np.allclose(const_data, expected_result) +def test_cant_change_data_in_const(): + arr_0 = np.ones([1, 3, 32, 32]) + ov_const = ops.constant(arr_0) + arr_1 = np.ones([1, 3, 32, 32]) + 1 + with pytest.raises(ValueError) as e: + ov_const.data[:] = arr_1 + assert 'assignment destination is read-only' in str(e.value) + + @pytest.mark.parametrize( ("ov_type", "numpy_dtype"), [