diff options
| author | Michael Löffler <michael@loeffler.io> | 2017-07-17 14:07:59 +0200 |
|---|---|---|
| committer | Michael Löffler <michael@loeffler.io> | 2017-07-17 14:07:59 +0200 |
| commit | c7cbc4c16f9764ae148d079b51fc970dcdc028b5 (patch) | |
| tree | 4afecd1f6b019daa1158aca4b7b6511a18942431 /test/test_compatibility.py | |
| parent | b2a4654b0cd24d4165cfb2c3a475c492e2697e2a (diff) | |
| download | urllib3-c7cbc4c16f9764ae148d079b51fc970dcdc028b5.tar.gz | |
Add compatibility for py3 cookiejar
Diffstat (limited to 'test/test_compatibility.py')
| -rw-r--r-- | test/test_compatibility.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test_compatibility.py b/test/test_compatibility.py index 429b9680..d27e9ea2 100644 --- a/test/test_compatibility.py +++ b/test/test_compatibility.py @@ -3,6 +3,8 @@ import warnings import pytest from urllib3.connection import HTTPConnection +from urllib3.response import HTTPResponse +from urllib3.packages.six.moves import http_cookiejar, urllib class TestVersionCompatibility(object): @@ -22,3 +24,17 @@ class TestVersionCompatibility(object): HTTPConnection('localhost', 12345, source_address='127.0.0.1') except TypeError as e: pytest.fail('HTTPConnection raised TypeError on source_adddress: %r' % e) + + +class TestCookiejar(object): + def test_extract(self): + request = urllib.request.Request('http://google.com') + cookiejar = http_cookiejar.CookieJar() + response = HTTPResponse() + + cookies = ["sessionhash=abcabcabcabcab; path=/; HttpOnly", + "lastvisit=1348253375; expires=Sat, 21-Sep-2050 18:49:35 GMT; path=/"] + for c in cookies: + response.headers.add('set-cookie', c) + cookiejar.extract_cookies(response, request) + assert len(cookiejar) == len(cookies) |
