Skip to content

Commit

Permalink
Basic tests for internationalized domain names.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa committed Oct 14, 2016
1 parent 49b69b5 commit 9337b4d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 9337b4d

Please sign in to comment.