@@ -443,6 +443,35 @@ def test_request_extra_query(self) -> None:
443
443
params = dict (request .url .params )
444
444
assert params == {"foo" : "2" }
445
445
446
+ def test_multipart_repeating_array (self , client : Finch ) -> None :
447
+ request = client ._build_request (
448
+ FinalRequestOptions .construct (
449
+ method = "get" ,
450
+ url = "/foo" ,
451
+ headers = {"Content-Type" : "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82" },
452
+ json_data = {"array" : ["foo" , "bar" ]},
453
+ files = [("foo.txt" , b"hello world" )],
454
+ )
455
+ )
456
+
457
+ assert request .read ().split (b"\r \n " ) == [
458
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
459
+ b'Content-Disposition: form-data; name="array[]"' ,
460
+ b"" ,
461
+ b"foo" ,
462
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
463
+ b'Content-Disposition: form-data; name="array[]"' ,
464
+ b"" ,
465
+ b"bar" ,
466
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
467
+ b'Content-Disposition: form-data; name="foo.txt"; filename="upload"' ,
468
+ b"Content-Type: application/octet-stream" ,
469
+ b"" ,
470
+ b"hello world" ,
471
+ b"--6b7ba517decee4a450543ea6ae821c82--" ,
472
+ b"" ,
473
+ ]
474
+
446
475
@pytest .mark .respx (base_url = base_url )
447
476
def test_basic_union_response (self , respx_mock : MockRouter ) -> None :
448
477
class Model1 (BaseModel ):
@@ -1179,6 +1208,35 @@ def test_request_extra_query(self) -> None:
1179
1208
params = dict (request .url .params )
1180
1209
assert params == {"foo" : "2" }
1181
1210
1211
+ def test_multipart_repeating_array (self , async_client : AsyncFinch ) -> None :
1212
+ request = async_client ._build_request (
1213
+ FinalRequestOptions .construct (
1214
+ method = "get" ,
1215
+ url = "/foo" ,
1216
+ headers = {"Content-Type" : "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82" },
1217
+ json_data = {"array" : ["foo" , "bar" ]},
1218
+ files = [("foo.txt" , b"hello world" )],
1219
+ )
1220
+ )
1221
+
1222
+ assert request .read ().split (b"\r \n " ) == [
1223
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
1224
+ b'Content-Disposition: form-data; name="array[]"' ,
1225
+ b"" ,
1226
+ b"foo" ,
1227
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
1228
+ b'Content-Disposition: form-data; name="array[]"' ,
1229
+ b"" ,
1230
+ b"bar" ,
1231
+ b"--6b7ba517decee4a450543ea6ae821c82" ,
1232
+ b'Content-Disposition: form-data; name="foo.txt"; filename="upload"' ,
1233
+ b"Content-Type: application/octet-stream" ,
1234
+ b"" ,
1235
+ b"hello world" ,
1236
+ b"--6b7ba517decee4a450543ea6ae821c82--" ,
1237
+ b"" ,
1238
+ ]
1239
+
1182
1240
@pytest .mark .respx (base_url = base_url )
1183
1241
async def test_basic_union_response (self , respx_mock : MockRouter ) -> None :
1184
1242
class Model1 (BaseModel ):
0 commit comments