@@ -344,13 +344,11 @@ def test_ipv6_missing_right_bracket() -> None:
344344 "http://[]/" ,
345345 "http://[1]/" ,
346346 "http://[127.0.0.1]/" ,
347- "http://]1dec:0:0:0::1[/" ,
348347 ),
349348 ids = (
350349 "empty-IPv6-like-URL" ,
351350 "no-colons-in-IPv6" ,
352351 "IPv4-inside-brackets" ,
353- "brackets-in-reversed-order" ,
354352 ),
355353)
356354def test_ipv6_invalid_url (url : str ) -> None :
@@ -360,6 +358,33 @@ def test_ipv6_invalid_url(url: str) -> None:
360358 URL (url )
361359
362360
361+ def test_ipv6_brackets_in_reversed_order () -> None :
362+ with pytest .raises (ValueError , match = "Invalid IPv6 URL" ):
363+ URL ("http://]1dec:0:0:0::1[/" )
364+
365+
366+ @pytest .mark .parametrize (
367+ "url" ,
368+ (
369+ "http://127.0.0.1[aa::ff]" ,
370+ "http://127.0.0.1[aa::ff]/" ,
371+ "http://127.0.0.1[aa::ff]:8080/" ,
372+ "http://[email protected] [aa::ff]/" , 373+ "http://example.com[::1]/" ,
374+ ),
375+ ids = (
376+ "ipv4-before-bracket" ,
377+ "ipv4-before-bracket-with-path" ,
378+ "ipv4-before-bracket-with-port" ,
379+ "userinfo-ipv4-before-bracket" ,
380+ "hostname-before-bracket" ,
381+ ),
382+ )
383+ def test_host_with_text_before_bracket_is_invalid (url : str ) -> None :
384+ with pytest .raises (ValueError , match = "Invalid IPv6 URL" ):
385+ URL (url )
386+
387+
363388def test_ipfuture_brackets_not_allowed () -> None :
364389 with pytest .raises (ValueError , match = "IPvFuture address is invalid" ):
365390 URL ("http://[v10]/" )
0 commit comments