@@ -52,61 +52,79 @@ def test_deprecation():
5252 deprecated_function ()
5353
5454
55- def test_get_url_dict ():
56- data = {
57- "http://example.com" : {
58- "protocol" : "http:" ,
59- "hostname" : "example.com" ,
60- "pathname" : "" ,
61- "full" : "http://example.com" ,
62- },
63- "http://example.com:443" : {
64- "protocol" : "http:" ,
65- "hostname" : "example.com" ,
66- "port" : "443" ,
67- "pathname" : "" ,
68- "full" : "http://example.com:443" ,
69- },
70- "http://example.com:443/a/b/c" : {
71- "protocol" : "http:" ,
72- "hostname" : "example.com" ,
73- "port" : "443" ,
74- "pathname" : "/a/b/c" ,
75- "full" : "http://example.com:443/a/b/c" ,
76- },
77- "https://example.com:443/" : {
78- "protocol" : "https:" ,
79- "hostname" : "example.com" ,
80- "port" : "443" ,
81- "pathname" : "/" ,
82- "full" : "https://example.com:443/" ,
83- },
84- "https://example.com:443/a/b/c?de" : {
85- "protocol" : "https:" ,
86- "hostname" : "example.com" ,
87- "port" : "443" ,
88- "pathname" : "/a/b/c" ,
89- "search" : "?de" ,
90- "full" : "https://example.com:443/a/b/c?de" ,
91- },
92- "https://[::ffff:a9fe:a9fe]/a/b/c?de" : {
93- "protocol" : "https:" ,
94- "hostname" : "::ffff:a9fe:a9fe" ,
95- "pathname" : "/a/b/c" ,
96- "search" : "?de" ,
97- "full" : "https://[::ffff:a9fe:a9fe]/a/b/c?de" ,
98- },
99- "http://[::ffff:a9fe:a9fe]:80/a/b/c?de" : {
100- "protocol" : "http:" ,
101- "hostname" : "::ffff:a9fe:a9fe" ,
102- "port" : "80" ,
103- "pathname" : "/a/b/c" ,
104- "search" : "?de" ,
105- "full" : "http://[::ffff:a9fe:a9fe]:80/a/b/c?de" ,
106- },
107- }
108- for url , expected in data .items ():
109- assert get_url_dict (url ) == expected
55+ @pytest .mark .parametrize (
56+ "url,expected" ,
57+ [
58+ (
59+ "http://example.com" ,
60+ {"protocol" : "http:" , "hostname" : "example.com" , "pathname" : "" , "full" : "http://example.com" },
61+ ),
62+ (
63+ "http://example.com:443" ,
64+ {
65+ "protocol" : "http:" ,
66+ "hostname" : "example.com" ,
67+ "port" : "443" ,
68+ "pathname" : "" ,
69+ "full" : "http://example.com:443" ,
70+ },
71+ ),
72+ (
73+ "http://example.com:443/a/b/c" ,
74+ {
75+ "protocol" : "http:" ,
76+ "hostname" : "example.com" ,
77+ "port" : "443" ,
78+ "pathname" : "/a/b/c" ,
79+ "full" : "http://example.com:443/a/b/c" ,
80+ },
81+ ),
82+ (
83+ "https://example.com:443/" ,
84+ {
85+ "protocol" : "https:" ,
86+ "hostname" : "example.com" ,
87+ "port" : "443" ,
88+ "pathname" : "/" ,
89+ "full" : "https://example.com:443/" ,
90+ },
91+ ),
92+ (
93+ "https://example.com:443/a/b/c?de" ,
94+ {
95+ "protocol" : "https:" ,
96+ "hostname" : "example.com" ,
97+ "port" : "443" ,
98+ "pathname" : "/a/b/c" ,
99+ "search" : "?de" ,
100+ "full" : "https://example.com:443/a/b/c?de" ,
101+ },
102+ ),
103+ (
104+ "https://[::ffff:a9fe:a9fe]/a/b/c?de" ,
105+ {
106+ "protocol" : "https:" ,
107+ "hostname" : "::ffff:a9fe:a9fe" ,
108+ "pathname" : "/a/b/c" ,
109+ "search" : "?de" ,
110+ "full" : "https://[::ffff:a9fe:a9fe]/a/b/c?de" ,
111+ },
112+ ),
113+ (
114+ "http://[::ffff:a9fe:a9fe]:80/a/b/c?de" ,
115+ {
116+ "protocol" : "http:" ,
117+ "hostname" : "::ffff:a9fe:a9fe" ,
118+ "port" : "80" ,
119+ "pathname" : "/a/b/c" ,
120+ "search" : "?de" ,
121+ "full" : "http://[::ffff:a9fe:a9fe]:80/a/b/c?de" ,
122+ },
123+ ),
124+ ],
125+ )
126+ def test_get_url_dict (url , expected ):
127+ assert get_url_dict (url ) == expected
110128
111129
112130def test_get_name_from_func ():
0 commit comments