@@ -994,15 +994,15 @@ class Utility_Tests(unittest.TestCase):
994994 # In Python 2 this test class was in test_urllib.
995995
996996 def test_splittype (self ):
997- splittype = urllib .parse ._splittype
997+ splittype = urllib .parse .splittype
998998 self .assertEqual (splittype ('type:opaquestring' ), ('type' , 'opaquestring' ))
999999 self .assertEqual (splittype ('opaquestring' ), (None , 'opaquestring' ))
10001000 self .assertEqual (splittype (':opaquestring' ), (None , ':opaquestring' ))
10011001 self .assertEqual (splittype ('type:' ), ('type' , '' ))
10021002 self .assertEqual (splittype ('type:opaque:string' ), ('type' , 'opaque:string' ))
10031003
10041004 def test_splithost (self ):
1005- splithost = urllib .parse ._splithost
1005+ splithost = urllib .parse .splithost
10061006 self .assertEqual (splithost ('//www.example.org:80/foo/bar/baz.html' ),
10071007 ('www.example.org:80' , '/foo/bar/baz.html' ))
10081008 self .assertEqual (splithost ('//www.example.org:80' ),
@@ -1031,7 +1031,7 @@ def test_splithost(self):
10311031 ('example.net' , '/file#' ))
10321032
10331033 def test_splituser (self ):
1034- splituser = urllib .parse ._splituser
1034+ splituser = urllib .parse .splituser
10351035 self .
assertEqual (
splituser (
'User:[email protected] :080' ),
10361036 ('User:Pass' , 'www.python.org:080' ))
10371037 self .assertEqual (splituser ('@www.python.org:080' ),
@@ -1046,7 +1046,7 @@ def test_splituser(self):
10461046 def test_splitpasswd (self ):
10471047 # Some of the password examples are not sensible, but it is added to
10481048 # confirming to RFC2617 and addressing issue4675.
1049- splitpasswd = urllib .parse ._splitpasswd
1049+ splitpasswd = urllib .parse .splitpasswd
10501050 self .assertEqual (splitpasswd ('user:ab' ), ('user' , 'ab' ))
10511051 self .assertEqual (splitpasswd ('user:a\n b' ), ('user' , 'a\n b' ))
10521052 self .assertEqual (splitpasswd ('user:a\t b' ), ('user' , 'a\t b' ))
@@ -1062,7 +1062,7 @@ def test_splitpasswd(self):
10621062 self .assertEqual (splitpasswd (':ab' ), ('' , 'ab' ))
10631063
10641064 def test_splitport (self ):
1065- splitport = urllib .parse ._splitport
1065+ splitport = urllib .parse .splitport
10661066 self .assertEqual (splitport ('parrot:88' ), ('parrot' , '88' ))
10671067 self .assertEqual (splitport ('parrot' ), ('parrot' , None ))
10681068 self .assertEqual (splitport ('parrot:' ), ('parrot' , None ))
@@ -1073,7 +1073,7 @@ def test_splitport(self):
10731073 self .assertEqual (splitport (':88' ), ('' , '88' ))
10741074
10751075 def test_splitnport (self ):
1076- splitnport = urllib .parse ._splitnport
1076+ splitnport = urllib .parse .splitnport
10771077 self .assertEqual (splitnport ('parrot:88' ), ('parrot' , 88 ))
10781078 self .assertEqual (splitnport ('parrot' ), ('parrot' , - 1 ))
10791079 self .assertEqual (splitnport ('parrot' , 55 ), ('parrot' , 55 ))
@@ -1087,7 +1087,7 @@ def test_splitnport(self):
10871087 def test_splitquery (self ):
10881088 # Normal cases are exercised by other tests; ensure that we also
10891089 # catch cases with no port specified (testcase ensuring coverage)
1090- splitquery = urllib .parse ._splitquery
1090+ splitquery = urllib .parse .splitquery
10911091 self .assertEqual (splitquery ('http://python.org/fake?foo=bar' ),
10921092 ('http://python.org/fake' , 'foo=bar' ))
10931093 self .assertEqual (splitquery ('http://python.org/fake?foo=bar?' ),
@@ -1097,7 +1097,7 @@ def test_splitquery(self):
10971097 self .assertEqual (splitquery ('?foo=bar' ), ('' , 'foo=bar' ))
10981098
10991099 def test_splittag (self ):
1100- splittag = urllib .parse ._splittag
1100+ splittag = urllib .parse .splittag
11011101 self .assertEqual (splittag ('http://example.com?foo=bar#baz' ),
11021102 ('http://example.com?foo=bar' , 'baz' ))
11031103 self .assertEqual (splittag ('http://example.com?foo=bar#' ),
@@ -1109,7 +1109,7 @@ def test_splittag(self):
11091109 ('http://example.com?foo=bar#baz' , 'boo' ))
11101110
11111111 def test_splitattr (self ):
1112- splitattr = urllib .parse ._splitattr
1112+ splitattr = urllib .parse .splitattr
11131113 self .assertEqual (splitattr ('/path;attr1=value1;attr2=value2' ),
11141114 ('/path' , ['attr1=value1' , 'attr2=value2' ]))
11151115 self .assertEqual (splitattr ('/path;' ), ('/path' , ['' ]))
@@ -1120,105 +1120,105 @@ def test_splitattr(self):
11201120 def test_splitvalue (self ):
11211121 # Normal cases are exercised by other tests; test pathological cases
11221122 # with no key/value pairs. (testcase ensuring coverage)
1123- splitvalue = urllib .parse ._splitvalue
1123+ splitvalue = urllib .parse .splitvalue
11241124 self .assertEqual (splitvalue ('foo=bar' ), ('foo' , 'bar' ))
11251125 self .assertEqual (splitvalue ('foo=' ), ('foo' , '' ))
11261126 self .assertEqual (splitvalue ('=bar' ), ('' , 'bar' ))
11271127 self .assertEqual (splitvalue ('foobar' ), ('foobar' , None ))
11281128 self .assertEqual (splitvalue ('foo=bar=baz' ), ('foo' , 'bar=baz' ))
11291129
11301130 def test_to_bytes (self ):
1131- result = urllib .parse ._to_bytes ('http://www.python.org' )
1131+ result = urllib .parse .to_bytes ('http://www.python.org' )
11321132 self .assertEqual (result , 'http://www.python.org' )
11331133 self .assertRaises (UnicodeError , urllib .parse ._to_bytes ,
11341134 'http://www.python.org/medi\u00e6 val' )
11351135
11361136 def test_unwrap (self ):
1137- url = urllib .parse ._unwrap ('<URL:type://host/path>' )
1137+ url = urllib .parse .unwrap ('<URL:type://host/path>' )
11381138 self .assertEqual (url , 'type://host/path' )
11391139
11401140
11411141class DeprecationTest (unittest .TestCase ):
11421142
11431143 def test_splittype_deprecation (self ):
11441144 with self .assertWarns (DeprecationWarning ) as cm :
1145- urllib .parse .splittype ()
1145+ urllib .parse .splittype ('' )
11461146 self .assertEqual (str (cm .warning ),
11471147 'urllib.parse.splittype() is deprecated as of 3.7, '
11481148 'use urllib.parse.urlparse() instead' )
11491149
11501150 def test_splithost_deprecation (self ):
11511151 with self .assertWarns (DeprecationWarning ) as cm :
1152- urllib .parse .splithost ()
1152+ urllib .parse .splithost ('' )
11531153 self .assertEqual (str (cm .warning ),
11541154 'urllib.parse.splithost() is deprecated as of 3.7, '
11551155 'use urllib.parse.urlparse() instead' )
11561156
11571157 def test_splituser_deprecation (self ):
11581158 with self .assertWarns (DeprecationWarning ) as cm :
1159- urllib .parse .splituser ()
1159+ urllib .parse .splituser ('' )
11601160 self .assertEqual (str (cm .warning ),
11611161 'urllib.parse.splituser() is deprecated as of 3.7, '
11621162 'use urllib.parse.urlparse() instead' )
11631163
11641164 def test_splitpasswd_deprecation (self ):
11651165 with self .assertWarns (DeprecationWarning ) as cm :
1166- urllib .parse .splitpasswd ()
1166+ urllib .parse .splitpasswd ('' )
11671167 self .assertEqual (str (cm .warning ),
11681168 'urllib.parse.splitpasswd() is deprecated as of 3.7, '
11691169 'use urllib.parse.urlparse() instead' )
11701170
11711171 def test_splitport_deprecation (self ):
11721172 with self .assertWarns (DeprecationWarning ) as cm :
1173- urllib .parse .splitport ()
1173+ urllib .parse .splitport ('' )
11741174 self .assertEqual (str (cm .warning ),
11751175 'urllib.parse.splitport() is deprecated as of 3.7, '
11761176 'use urllib.parse.urlparse() instead' )
11771177
11781178 def test_splitnport_deprecation (self ):
11791179 with self .assertWarns (DeprecationWarning ) as cm :
1180- urllib .parse .splitnport ()
1180+ urllib .parse .splitnport ('' )
11811181 self .assertEqual (str (cm .warning ),
11821182 'urllib.parse.splitnport() is deprecated as of 3.7, '
11831183 'use urllib.parse.urlparse() instead' )
11841184
11851185 def test_splitquery_deprecation (self ):
11861186 with self .assertWarns (DeprecationWarning ) as cm :
1187- urllib .parse .splitquery ()
1187+ urllib .parse .splitquery ('' )
11881188 self .assertEqual (str (cm .warning ),
11891189 'urllib.parse.splitquery() is deprecated as of 3.7, '
11901190 'use urllib.parse.urlparse() instead' )
11911191
11921192 def test_splittag_deprecation (self ):
11931193 with self .assertWarns (DeprecationWarning ) as cm :
1194- urllib .parse .splittag ()
1194+ urllib .parse .splittag ('' )
11951195 self .assertEqual (str (cm .warning ),
11961196 'urllib.parse.splittag() is deprecated as of 3.7, '
11971197 'use urllib.parse.urlparse() instead' )
11981198
11991199 def test_splitattr_deprecation (self ):
12001200 with self .assertWarns (DeprecationWarning ) as cm :
1201- urllib .parse .splitattr ()
1201+ urllib .parse .splitattr ('' )
12021202 self .assertEqual (str (cm .warning ),
12031203 'urllib.parse.splitattr() is deprecated as of 3.7, '
12041204 'use urllib.parse.urlparse() instead' )
12051205
12061206 def test_splitvalue_deprecation (self ):
12071207 with self .assertWarns (DeprecationWarning ) as cm :
1208- urllib .parse .splitvalue ()
1208+ urllib .parse .splitvalue ('' )
12091209 self .assertEqual (str (cm .warning ),
12101210 'urllib.parse.splitvalue() is deprecated as of 3.7, '
1211- 'use urllib.parse.urlparse () instead' )
1211+ 'use urllib.parse.parse_qsl () instead' )
12121212
12131213 def test_to_bytes_deprecation (self ):
12141214 with self .assertWarns (DeprecationWarning ) as cm :
1215- urllib .parse .to_bytes ()
1215+ urllib .parse .to_bytes ('' )
12161216 self .assertEqual (str (cm .warning ),
12171217 'urllib.parse.to_bytes() is deprecated as of 3.7' )
12181218
12191219 def test_unwrap (self ):
12201220 with self .assertWarns (DeprecationWarning ) as cm :
1221- urllib .parse .unwrap ()
1221+ urllib .parse .unwrap ('' )
12221222 self .assertEqual (str (cm .warning ),
12231223 'urllib.parse.unwrap() is deprecated as of 3.7' )
12241224
0 commit comments