From e15280e49d9ee15bd7b5f3a00862d5f0a720b8e1 Mon Sep 17 00:00:00 2001 From: Dmitry Klimenko Date: Fri, 18 Nov 2016 19:04:51 +0300 Subject: [PATCH] fixed: httpbin with unicode auth --- tests/test_requests.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_requests.py b/tests/test_requests.py index 88e48c32..69c9d972 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -18,7 +18,7 @@ from requests.adapters import HTTPAdapter from requests.auth import HTTPDigestAuth, _basic_auth_str from requests.compat import ( Morsel, cookielib, getproxies, str, urlparse, - builtin_str, OrderedDict) + builtin_str, OrderedDict, bytes) from requests.cookies import ( cookiejar_from_dict, morsel_to_cookie, merge_cookies) from requests.exceptions import ( @@ -467,7 +467,18 @@ class TestRequests: )) def test_BASICAUTH_TUPLE_HTTP_200_OK_GET(self, httpbin, username, password): auth = (username, password) - url = httpbin('get') + + if isinstance(username, bytes): + httpbin_username = username.decode('latin1') + else: + httpbin_username = username + + if isinstance(password, bytes): + httpbin_password = password.decode('latin1') + else: + httpbin_password = password + + url = httpbin('basic-auth', httpbin_username, httpbin_password) r = requests.Request('GET', url, auth=auth) p = r.prepare()