Basic tests for internationalized domain names.

This commit is contained in:
Cory Benfield
2016-10-14 10:53:15 +01:00
parent 49b69b57db
commit 9337b4d95d
+37
View File
@@ -1888,3 +1888,40 @@ def test_vendor_aliases():
with pytest.raises(ImportError):
from requests.packages import webbrowser
class TestPreparingURLs(object):
@pytest.mark.parametrize(
'url,expected',
(
('http://google.com', 'http://google.com/'),
(u'http://ジェーピーニック.jp', u'http://xn--hckqz9bzb1cyrb.jp/'),
(
u'http://ジェーピーニック.jp'.encode('utf-8'),
u'http://xn--hckqz9bzb1cyrb.jp/'
),
(u'http://straße.de/straße', u'http://xn--strae-oqa.de/stra%C3%9Fe'),
(
u'http://straße.de/straße'.encode('utf-8'),
u'http://xn--strae-oqa.de/stra%C3%9Fe'
),
)
)
def test_preparing_url(self, url, expected):
r = requests.Request(url=url)
p = r.prepare()
assert p.url == expected
@pytest.mark.parametrize(
'url',
(
b"http://*.google.com",
b"http://*",
u"http://*.google.com",
u"http://*",
)
)
def test_preparing_bad_url(self, url):
r = requests.Request(url=url)
with pytest.raises(requests.exceptions.InvalidURL):
r.prepare()