@@ -229,3 +229,28 @@ def test_list_delitem_out_of_by(seq: list[int], i: int) -> None:
229
229
with pytest .raises (IndexError ) as e :
230
230
del a [i ]
231
231
assert str (e .value ) == f"list index out of range: { i } "
232
+
233
+
234
+ def test_list_to_py_0 () -> None :
235
+ a = List ([1 , 2 , 3 ]).py ()
236
+ assert isinstance (a , list )
237
+
238
+
239
+ def test_list_to_py_1 () -> None :
240
+ a = List ([{"a" : 1 }, ["b" ], 1 , 2.0 , "anything" ]).py ()
241
+ assert isinstance (a , list )
242
+ assert len (a ) == 5
243
+ assert isinstance (a [0 ], dict )
244
+ assert isinstance (a [1 ], list )
245
+ assert isinstance (a [2 ], int )
246
+ assert isinstance (a [3 ], float )
247
+ assert isinstance (a [4 ], str )
248
+ assert isinstance (a [0 ], dict )
249
+ # make sure those types are exactly Python's `str`, `int`, `float`
250
+ assert len (a [0 ]) == 1 and isinstance (a [0 ], dict )
251
+ assert a [0 ]["a" ] == 1 and type (next (a [0 ].__iter__ ())) is str
252
+ assert len (a [1 ]) == 1 and isinstance (a [1 ], list )
253
+ assert a [1 ][0 ] == "b" and type (a [1 ][0 ]) is str
254
+ assert a [2 ] == 1 and type (a [2 ]) is int
255
+ assert a [3 ] == 2.0 and type (a [3 ]) is float
256
+ assert a [4 ] == "anything" and type (a [4 ]) is str
0 commit comments