mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
updated tests with IDNA encoded and IPv6 urls
This commit is contained in:
@@ -2093,6 +2093,7 @@ class TestPreparingURLs(object):
|
||||
(
|
||||
('http://google.com', 'http://google.com/'),
|
||||
(u'http://ジェーピーニック.jp', u'http://xn--hckqz9bzb1cyrb.jp/'),
|
||||
(u'http://xn--n3h.net/', u'http://xn--n3h.net/'),
|
||||
(
|
||||
u'http://ジェーピーニック.jp'.encode('utf-8'),
|
||||
u'http://xn--hckqz9bzb1cyrb.jp/'
|
||||
@@ -2113,6 +2114,18 @@ class TestPreparingURLs(object):
|
||||
u'http://Königsgäßchen.de/straße'.encode('utf-8'),
|
||||
u'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'
|
||||
),
|
||||
(
|
||||
b'http://xn--n3h.net/',
|
||||
u'http://xn--n3h.net/'
|
||||
),
|
||||
(
|
||||
b'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/',
|
||||
u'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'
|
||||
),
|
||||
(
|
||||
u'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/',
|
||||
u'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'
|
||||
)
|
||||
)
|
||||
)
|
||||
def test_preparing_url(self, url, expected):
|
||||
@@ -2127,6 +2140,7 @@ class TestPreparingURLs(object):
|
||||
b"http://*",
|
||||
u"http://*.google.com",
|
||||
u"http://*",
|
||||
u"http://☃.net/"
|
||||
)
|
||||
)
|
||||
def test_preparing_bad_url(self, url):
|
||||
|
||||
@@ -17,6 +17,7 @@ from requests.utils import (
|
||||
to_key_val_list, to_native_string,
|
||||
unquote_header_value, unquote_unreserved,
|
||||
urldefragauth, add_dict_to_cookiejar)
|
||||
from requests._internal_utils import unicode_is_ascii
|
||||
|
||||
from .compat import StringIO, cStringIO
|
||||
|
||||
@@ -515,6 +516,7 @@ def test_should_bypass_proxies(url, expected, monkeypatch):
|
||||
monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')
|
||||
assert should_bypass_proxies(url) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'cookiejar', (
|
||||
compat.cookielib.CookieJar(),
|
||||
@@ -529,3 +531,14 @@ def test_add_dict_to_cookiejar(cookiejar):
|
||||
cj = add_dict_to_cookiejar(cookiejar, cookiedict)
|
||||
cookies = dict((cookie.name, cookie.value) for cookie in cj)
|
||||
assert cookiedict == cookies
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'value, expected', (
|
||||
(u'test', True),
|
||||
(u'æíöû', False),
|
||||
(u'ジェーピーニック', False),
|
||||
)
|
||||
)
|
||||
def test_unicode_is_ascii(value, expected):
|
||||
assert unicode_is_ascii(value) is expected
|
||||
|
||||
Reference in New Issue
Block a user