@@ -51,6 +51,7 @@ def test_path() -> None:
5151 [0.0 , 1.0 ],
5252 ((0 , 1 ),),
5353 [(0 , 1 )],
54+ [[0 , 1 ]],
5455 ((0.0 , 1.0 ),),
5556 [(0.0 , 1.0 )],
5657 array .array ("f" , [0 , 1 ]),
@@ -68,6 +69,34 @@ def test_path_constructors(
6869 assert list (p ) == [(0.0 , 1.0 )]
6970
7071
72+ @pytest .mark .parametrize (
73+ "coords, expected" ,
74+ (
75+ ([[0 , 1 ], [2 , 3 ]], [(0.0 , 1.0 ), (2.0 , 3.0 )]),
76+ ([[0.0 , 1.0 ], [2.0 , 3.0 ]], [(0.0 , 1.0 ), (2.0 , 3.0 )]),
77+ ),
78+ )
79+ def test_path_list_of_lists (
80+ coords : list [list [float ]], expected : list [tuple [float , float ]]
81+ ) -> None :
82+ p = ImagePath .Path (coords )
83+ assert list (p ) == expected
84+
85+
86+ @pytest .mark .parametrize (
87+ "coords, message" ,
88+ (
89+ ([[1 , 2 , 3 ]], "coordinate list must contain exactly 2 coordinates" ),
90+ ([[1 ]], "coordinate list must contain exactly 2 coordinates" ),
91+ ([[[1 , 2 ], [3 , 4 ]]], "coordinate list must contain numbers" ),
92+ ([["a" , "b" ]], "coordinate list must contain numbers" ),
93+ ),
94+ )
95+ def test_invalid_list_coords (coords : list [list [object ]], message : str ) -> None :
96+ with pytest .raises (ValueError , match = message ):
97+ ImagePath .Path (coords )
98+
99+
71100def test_invalid_path_constructors () -> None :
72101 # Arrange / Act
73102 with pytest .raises (ValueError , match = "incorrect coordinate type" ):
0 commit comments