8000 Array indexing test cases · pythonnet/pythonnet@0ee7631 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ee7631

Browse files
committed
Array indexing test cases
1 parent 0f33f71 commit 0ee7631

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/tests/test_array.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,15 @@ def test_typed_array():
836836

837837
with pytest.raises(TypeError):
838838
ob = Test.TypedArrayTest()
839-
ob.items["wrong"] = "wrong"
839+
ob.items["wrong"] = Spam("0")
840+
841+
with pytest.raises(TypeError):
842+
ob = Test.TypedArrayTest()
843+
_ = ob.items[0.5]
840844

845+
with pytest.raises(TypeError):
846+
ob = Test.TypedArrayTest()
847+
ob.items[0.5] = Spam("0")
841848

842849
def test_multi_dimensional_array():
843850
"""Test multi-dimensional arrays."""
@@ -901,8 +908,23 @@ def test_multi_dimensional_array():
901908

902909
with pytest.raises(TypeError):
903910
ob = Test.MultiDimensionalArrayTest()
904-
ob[0, 0] = "wrong"
911+
ob.items[0, 0] = "wrong"
905912

913+
with pytest.raises(TypeError):
914+
ob = Test.MultiDimensionalArrayTest()
915+
ob["0", 0] = 0
916+
917+
with pytest.raises(TypeError):
918+
ob = Test.MultiDimensionalArrayTest()
919+
ob.items["0", 0] = 0
920+
921+
with pytest.raises(TypeError):
922+
ob = Test.MultiDimensionalArrayTest()
923+
_ = ob.items[0.5, 0]
924+
925+
with pytest.raises(TypeError):
926+
ob = Test.MultiDimensionalArrayTest()
927+
ob.items[0.5, 0] = 0
906928

907929
def test_array_iteration():
908930
"""Test array iteration."""
@@ -1189,6 +1211,15 @@ def test_create_array_from_shape():
11891211
with pytest.raises(ValueError):
11901212
Array[int](-1)
11911213

1214+
with pytest.raises(TypeError):
1215+
Array[int]('1')
1216+
1217+
with pytest.raises(ValueError):
1218+
Array[int](-1, -1)
1219+
1220+
with pytest.raises(TypeError):
1221+
Array[int]('1', '1')
1222+
11921223
def test_special_array_creation():
11931224
"""Test using the Array[<type>] syntax for creating arrays."""
11941225
from Python.Test import ISayHello1, InterfaceTest, ShortEnum

0 commit comments

Comments
 (0)
0