diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index b588102c07..34f88af7eb 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -50,7 +50,7 @@ from zerver.lib.str_utils import NonBinaryStr from contextlib import contextmanager import six -API_KEYS = {} # type: Dict[str, str] +API_KEYS = {} # type: Dict[text_type, text_type] @contextmanager def stub(obj, name, f): @@ -285,16 +285,16 @@ class AuthedTestCase(TestCase): 'terms': True}) def get_api_key(self, email): - # type: (str) -> str + # type: (text_type) -> text_type if email not in API_KEYS: API_KEYS[email] = get_user_profile_by_email(email).api_key return API_KEYS[email] def api_auth(self, email): - # type: (str) -> Dict[str, str] - credentials = "%s:%s" % (email, self.get_api_key(email)) + # type: (text_type) -> Dict[str, text_type] + credentials = u"%s:%s" % (email, self.get_api_key(email)) return { - 'HTTP_AUTHORIZATION': 'Basic ' + base64.b64encode(credentials) + 'HTTP_AUTHORIZATION': u'Basic ' + base64.b64encode(credentials.encode('utf-8')).decode('utf-8') } def get_streams(self, email): diff --git a/zerver/tests/test_external.py b/zerver/tests/test_external.py index ef62d000c5..43c1a6171e 100644 --- a/zerver/tests/test_external.py +++ b/zerver/tests/test_external.py @@ -22,9 +22,10 @@ import DNS import mock import time import ujson -from six.moves import urllib +from six.moves import urllib from six.moves import range +from six import text_type class MITNameTest(TestCase): def test_valid_hesiod(self): @@ -66,7 +67,7 @@ class RateLimitTests(AuthedTestCase): remove_ratelimit_rule(1, 5) def send_api_message(self, email, api_key, content): - # type: (str, str, str) -> HttpResponse + # type: (text_type, text_type, text_type) -> HttpResponse return self.client.post("/api/v1/send_message", {"type": "stream", "to": "Verona", "client": "test suite",