From dddfcb2826df9ae4ab7a50bc28184ea4c41daf3a Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Wed, 8 Jul 2015 12:38:14 +0300 Subject: [PATCH] Fix test_logger in Python 3.2. --- gunicorn/glogging.py | 4 +++- tox.ini | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index 212c5436..e0819284 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -378,7 +378,9 @@ class Logger(object): auth = http_auth.split(" ", 1) if len(auth) == 2: try: - auth = base64.b64decode(auth[1].strip()) + # b64decode doesn't accept unicode in Python < 3.3 + # so we need to convert it to a byte string + auth = base64.b64decode(auth[1].strip().encode('utf-8')) if PY3: # b64decode returns a byte string in Python 3 auth = auth.decode('utf-8') auth = auth.split(":", 1) diff --git a/tox.ini b/tox.ini index b0d5d839..380d8ac1 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ skipsdist = True [testenv] usedevelop = True -commands = py.test tests/ +commands = py.test {posargs:tests/} deps = -rrequirements_test.txt py26: unittest2