@@ -994,15 +994,15 @@ class Utility_Tests(unittest.TestCase):
994
994
# In Python 2 this test class was in test_urllib.
995
995
996
996
def test_splittype (self ):
997
- splittype = urllib .parse ._splittype
997
+ splittype = urllib .parse .splittype
998
998
self .assertEqual (splittype ('type:opaquestring' ), ('type' , 'opaquestring' ))
999
999
self .assertEqual (splittype ('opaquestring' ), (None , 'opaquestring' ))
1000
1000
self .assertEqual (splittype (':opaquestring' ), (None , ':opaquestring' ))
1001
1001
self .assertEqual (splittype ('type:' ), ('type' , '' ))
1002
1002
self .assertEqual (splittype ('type:opaque:string' ), ('type' , 'opaque:string' ))
1003
1003
1004
1004
def test_splithost (self ):
1005
- splithost = urllib .parse ._splithost
1005
+ splithost = urllib .parse .splithost
1006
1006
self .assertEqual (splithost ('//www.example.org:80/foo/bar/baz.html' ),
1007
1007
('www.example.org:80' , '/foo/bar/baz.html' ))
1008
1008
self .assertEqual (splithost ('//www.example.org:80' ),
@@ -1031,7 +1031,7 @@ def test_splithost(self):
1031
1031
('example.net' , '/file#' ))
1032
1032
1033
1033
def test_splituser (self ):
1034
- splituser = urllib .parse ._splituser
1034
+ splituser = urllib .parse .splituser
1035
1035
self .
assertEqual (
splituser (
'User:[email protected] :080' ),
1036
1036
('User:Pass' , 'www.python.org:080' ))
1037
1037
self .assertEqual (splituser ('@www.python.org:080' ),
@@ -1046,7 +1046,7 @@ def test_splituser(self):
1046
1046
def test_splitpasswd (self ):
1047
1047
# Some of the password examples are not sensible, but it is added to
1048
1048
# confirming to RFC2617 and addressing issue4675.
1049
- splitpasswd = urllib .parse ._splitpasswd
1049
+ splitpasswd = urllib .parse .splitpasswd
1050
1050
self .assertEqual (splitpasswd ('user:ab' ), ('user' , 'ab' ))
1051
1051
self .assertEqual (splitpasswd ('user:a\n b' ), ('user' , 'a\n b' ))
1052
1052
self .assertEqual (splitpasswd ('user:a\t b' ), ('user' , 'a\t b' ))
@@ -1062,7 +1062,7 @@ def test_splitpasswd(self):
1062
1062
self .assertEqual (splitpasswd (':ab' ), ('' , 'ab' ))
1063
1063
1064
1064
def test_splitport (self ):
1065
- splitport = urllib .parse ._splitport
1065
+ splitport = urllib .parse .splitport
1066
1066
self .assertEqual (splitport ('parrot:88' ), ('parrot' , '88' ))
1067
1067
self .assertEqual (splitport ('parrot' ), ('parrot' , None ))
1068
1068
self .assertEqual (splitport ('parrot:' ), ('parrot' , None ))
@@ -1073,7 +1073,7 @@ def test_splitport(self):
1073
1073
self .assertEqual (splitport (':88' ), ('' , '88' ))
1074
1074
1075
1075
def test_splitnport (self ):
1076
- splitnport = urllib .parse ._splitnport
1076
+ splitnport = urllib .parse .splitnport
1077
1077
self .assertEqual (splitnport ('parrot:88' ), ('parrot' , 88 ))
1078
1078
self .assertEqual (splitnport ('parrot' ), ('parrot' , - 1 ))
1079
1079
self .assertEqual (splitnport ('parrot' , 55 ), ('parrot' , 55 ))
@@ -1087,7 +1087,7 @@ def test_splitnport(self):
1087
1087
def test_splitquery (self ):
1088
1088
# Normal cases are exercised by other tests; ensure that we also
1089
1089
# catch cases with no port specified (testcase ensuring coverage)
1090
- splitquery = urllib .parse ._splitquery
1090
+ splitquery = urllib .parse .splitquery
1091
1091
self .assertEqual (splitquery ('http://python.org/fake?foo=bar' ),
1092
1092
('http://python.org/fake' , 'foo=bar' ))
1093
1093
self .assertEqual (splitquery ('http://python.org/fake?foo=bar?' ),
@@ -1097,7 +1097,7 @@ def test_splitquery(self):
1097
1097
self .assertEqual (splitquery ('?foo=bar' ), ('' , 'foo=bar' ))
1098
1098
1099
1099
def test_splittag (self ):
1100
- splittag = urllib .parse ._splittag
1100
+ splittag = urllib .parse .splittag
1101
1101
self .assertEqual (splittag ('http://example.com?foo=bar#baz' ),
1102
1102
('http://example.com?foo=bar' , 'baz' ))
1103
1103
self .assertEqual (splittag ('http://example.com?foo=bar#' ),
@@ -1109,7 +1109,7 @@ def test_splittag(self):
1109
1109
('http://example.com?foo=bar#baz' , 'boo' ))
1110
1110
1111
1111
def test_splitattr (self ):
1112
- splitattr = urllib .parse ._splitattr
1112
+ splitattr = urllib .parse .splitattr
1113
1113
self .assertEqual (splitattr ('/path;attr1=value1;attr2=value2' ),
1114
1114
('/path' , ['attr1=value1' , 'attr2=value2' ]))
1115
1115
self .assertEqual (splitattr ('/path;' ), ('/path' , ['' ]))
@@ -1120,105 +1120,105 @@ def test_splitattr(self):
1120
1120
def test_splitvalue (self ):
1121
1121
# Normal cases are exercised by other tests; test pathological cases
1122
1122
# with no key/value pairs. (testcase ensuring coverage)
1123
- splitvalue = urllib .parse ._splitvalue
1123
+ splitvalue = urllib .parse .splitvalue
1124
1124
self .assertEqual (splitvalue ('foo=bar' ), ('foo' , 'bar' ))
1125
1125
self .assertEqual (splitvalue ('foo=' ), ('foo' , '' ))
1126
1126
self .assertEqual (splitvalue ('=bar' ), ('' , 'bar' ))
1127
1127
self .assertEqual (splitvalue ('foobar' ), ('foobar' , None ))
1128
1128
self .assertEqual (splitvalue ('foo=bar=baz' ), ('foo' , 'bar=baz' ))
1129
1129
1130
1130
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' )
1132
1132
self .assertEqual (result , 'http://www.python.org' )
1133
1133
self .assertRaises (UnicodeError , urllib .parse ._to_bytes ,
1134
1134
'http://www.python.org/medi\u00e6 val' )
1135
1135
1136
1136
def test_unwrap (self ):
1137
- url = urllib .parse ._unwrap ('<URL:type://host/path>' )
1137
+ url = urllib .parse .unwrap ('<URL:type://host/path>' )
1138
1138
self .assertEqual (url , 'type://host/path' )
1139
1139
1140
1140
1141
1141
class DeprecationTest (unittest .TestCase ):
1142
1142
1143
1143
def test_splittype_deprecation (self ):
1144
1144
with self .assertWarns (DeprecationWarning ) as cm :
1145
- urllib .parse .splittype ()
1145
+ urllib .parse .splittype ('' )
1146
1146
self .assertEqual (str (cm .warning ),
1147
1147
'urllib.parse.splittype() is deprecated as of 3.7, '
1148
1148
'use urllib.parse.urlparse() instead' )
1149
1149
1150
1150
def test_splithost_deprecation (self ):
1151
1151
with self .assertWarns (DeprecationWarning ) as cm :
1152
- urllib .parse .splithost ()
1152
+ urllib .parse .splithost ('' )
1153
1153
self .assertEqual (str (cm .warning ),
1154
1154
'urllib.parse.splithost() is deprecated as of 3.7, '
1155
1155
'use urllib.parse.urlparse() instead' )
1156
1156
1157
1157
def test_splituser_deprecation (self ):
1158
1158
with self .assertWarns (DeprecationWarning ) as cm :
1159
- urllib .parse .splituser ()
1159
+ urllib .parse .splituser ('' )
1160
1160
self .assertEqual (str (cm .warning ),
1161
1161
'urllib.parse.splituser() is deprecated as of 3.7, '
1162
1162
'use urllib.parse.urlparse() instead' )
1163
1163
1164
1164
def test_splitpasswd_deprecation (self ):
1165
1165
with self .assertWarns (DeprecationWarning ) as cm :
1166
- urllib .parse .splitpasswd ()
1166
+ urllib .parse .splitpasswd ('' )
1167
1167
self .assertEqual (str (cm .warning ),
1168
1168
'urllib.parse.splitpasswd() is deprecated as of 3.7, '
1169
1169
'use urllib.parse.urlparse() instead' )
1170
1170
1171
1171
def test_splitport_deprecation (self ):
1172
1172
with self .assertWarns (DeprecationWarning ) as cm :
1173
- urllib .parse .splitport ()
1173
+ urllib .parse .splitport ('' )
1174
1174
self .assertEqual (str (cm .warning ),
1175
1175
'urllib.parse.splitport() is deprecated as of 3.7, '
1176
1176
'use urllib.parse.urlparse() instead' )
1177
1177
1178
1178
def test_splitnport_deprecation (self ):
1179
1179
with self .assertWarns (DeprecationWarning ) as cm :
1180
- urllib .parse .splitnport ()
1180
+ urllib .parse .splitnport ('' )
1181
1181
self .assertEqual (str (cm .warning ),
1182
1182
'urllib.parse.splitnport() is deprecated as of 3.7, '
1183
1183
'use urllib.parse.urlparse() instead' )
1184
1184
1185
1185
def test_splitquery_deprecation (self ):
1186
1186
with self .assertWarns (DeprecationWarning ) as cm :
1187
- urllib .parse .splitquery ()
1187
+ urllib .parse .splitquery ('' )
1188
1188
self .assertEqual (str (cm .warning ),
1189
1189
'urllib.parse.splitquery() is deprecated as of 3.7, '
1190
1190
'use urllib.parse.urlparse() instead' )
1191
1191
1192
1192
def test_splittag_deprecation (self ):
1193
1193
with self .assertWarns (DeprecationWarning ) as cm :
1194
- urllib .parse .splittag ()
1194
+ urllib .parse .splittag ('' )
1195
1195
self .assertEqual (str (cm .warning ),
1196
1196
'urllib.parse.splittag() is deprecated as of 3.7, '
1197
1197
'use urllib.parse.urlparse() instead' )
1198
1198
1199
1199
def test_splitattr_deprecation (self ):
1200
1200
with self .assertWarns (DeprecationWarning ) as cm :
1201
- urllib .parse .splitattr ()
1201
+ urllib .parse .splitattr ('' )
1202
1202
self .assertEqual (str (cm .warning ),
1203
1203
'urllib.parse.splitattr() is deprecated as of 3.7, '
1204
1204
'use urllib.parse.urlparse() instead' )
1205
1205
1206
1206
def test_splitvalue_deprecation (self ):
1207
1207
with self .assertWarns (DeprecationWarning ) as cm :
1208
- urllib .parse .splitvalue ()
1208
+ urllib .parse .splitvalue ('' )
1209
1209
self .assertEqual (str (cm .warning ),
1210
1210
'urllib.parse.splitvalue() is deprecated as of 3.7, '
1211
- 'use urllib.parse.urlparse () instead' )
1211
+ 'use urllib.parse.parse_qsl () instead' )
1212
1212
1213
1213
def test_to_bytes_deprecation (self ):
1214
1214
with self .assertWarns (DeprecationWarning ) as cm :
1215
- urllib .parse .to_bytes ()
1215
+ urllib .parse .to_bytes ('' )
1216
1216
self .assertEqual (str (cm .warning ),
1217
1217
'urllib.parse.to_bytes() is deprecated as of 3.7' )
1218
1218
1219
1219
def test_unwrap (self ):
1220
1220
with self .assertWarns (DeprecationWarning ) as cm :
1221
- urllib .parse .unwrap ()
1221
+ urllib .parse .unwrap ('' )
1222
1222
self .assertEqual (str (cm .warning ),
1223
1223
'urllib.parse.unwrap() is deprecated as of 3.7' )
1224
1224
0 commit comments