1- import io
21import os
32import tempfile
43
@@ -45,6 +44,24 @@ def test_url():
4544 new = URL (** u .components ._asdict ())
4645 assert new == u
4746
47+ ipv6_url = URL ("https://[fe::2]:12345" )
48+ new = ipv6_url .replace (port = 8080 )
49+ assert new == "https://[fe::2]:8080"
50+
51+ new = ipv6_url .replace (username = "username" , password = "password" )
52+ assert new == "https://username:password@[fe::2]:12345"
53+ assert new .netloc == "username:password@[fe::2]:12345"
54+
55+ ipv6_url = URL ("https://[fe::2]" )
56+ new = ipv6_url .replace (port = 123 )
57+ assert new == "https://[fe::2]:123"
58+
59+ url = URL ("http://u:p@host/" )
60+ assert url .replace (hostname = "bar" ) == URL ("http://u:p@bar/" )
61+
62+ url = URL ("http://u:p@host:80" )
63+ assert url .replace (port = 88 ) == URL ("http://u:p@host:88" )
64+
4865
4966def test_url_query_params ():
5067 u = URL ("https://example.org/path/?page=3" )
@@ -198,7 +215,7 @@ def test_url_blank_params():
198215 assert "abc" in q
199216 assert "def" in q
200217 assert "b" in q
201- assert len (q . get ( "abc" ) ) == 0
218+ assert len (q [ "abc" ] ) == 0
202219 assert len (q ["a" ]) == 3
203220 assert list (q .keys ()) == ["a" , "abc" , "def" , "b" ]
204221
@@ -284,7 +301,7 @@ async def test_async_big_upload_file():
284301
285302
286303def test_formdata ():
287- upload = io . BytesIO ( b"test" )
304+ upload = UploadFile ( "filename" , Headers () )
288305 form = FormData ([("a" , "123" ), ("a" , "456" ), ("b" , upload )])
289306 assert "a" in form
290307 assert "A" not in form
@@ -309,7 +326,9 @@ def test_formdata():
309326
310327
311328def test_mutable_multi_mapping ():
312- q = MutableMultiMapping ([("a" , "123" ), ("a" , "456" ), ("b" , "789" )])
329+ q : MutableMultiMapping [str , str ] = MutableMultiMapping (
330+ [("a" , "123" ), ("a" , "456" ), ("b" , "789" )]
331+ )
313332 assert "a" in q
314333 assert "A" not in q
315334 assert "c" not in q
@@ -393,7 +412,7 @@ def test_mutable_multi_mapping():
393412 q = MutableMultiMapping ([("a" , "123" ), ("b" , "456" )])
394413 q .update ({"a" : "789" })
395414 assert q .getlist ("a" ) == ["789" ]
396- q == MutableMultiMapping ([("a" , "789" ), ("b" , "456" )])
415+ assert q == MutableMultiMapping ([("a" , "789" ), ("b" , "456" )])
397416
398417 q = MutableMultiMapping ([("a" , "123" ), ("b" , "456" )])
399418 q .update (q )
0 commit comments