Python < 3 compatibility.

This commit is contained in:
Max Peterson 2014-04-28 13:10:34 +01:00
parent 1c777ffe8b
commit 170fa10ae0

View File

@ -199,7 +199,13 @@ class TokenAuthTests(TestCase):
"""Ensure generate_key returns a string"""
token = Token()
key = token.generate_key()
self.assertTrue(isinstance(key, str))
try:
# added in Python < 3
base = unicode
except NameError:
# added in Python >= 3
base = str
self.assertTrue(isinstance(key, base))
def test_token_login_json(self):
"""Ensure token login view using JSON POST works."""