diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index 1919e52862..b3420f45bd 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -6,7 +6,7 @@ from django.test import override_settings from django_auth_ldap.backend import _LDAPUser from django.contrib.auth import authenticate from django.test.client import RequestFactory -from typing import Any, Callable, Dict, List, Optional, Text, Tuple +from typing import Any, Callable, Dict, List, Optional, Tuple from builtins import object from oauth2client.crypt import AppIdentityError from django.core import signing @@ -66,7 +66,7 @@ import ujson from zerver.lib.test_helpers import MockLDAP, load_subdomain_token class AuthBackendTest(ZulipTestCase): - def get_username(self, email_to_username: Optional[Callable[[Text], Text]]=None) -> Text: + def get_username(self, email_to_username: Optional[Callable[[str], str]]=None) -> str: username = self.example_email('hamlet') if email_to_username is not None: username = email_to_username(self.example_email('hamlet')) @@ -776,7 +776,7 @@ class GoogleOAuthTest(ZulipTestCase): *, subdomain: Optional[str]=None, mobile_flow_otp: Optional[str]=None, is_signup: Optional[str]=None, - next: Text='') -> HttpResponse: + next: str='') -> HttpResponse: url = "/accounts/login/google/" params = {} headers = {} @@ -898,7 +898,7 @@ class GoogleSubdomainLoginTest(GoogleOAuthTest): return self.client_get(url_path, subdomain=subdomain) def test_redirect_to_next_url_for_log_into_subdomain(self) -> None: - def test_redirect_to_next_url(next: Text='') -> HttpResponse: + def test_redirect_to_next_url(next: str='') -> HttpResponse: data = {'name': 'Hamlet', 'email': self.example_email("hamlet"), 'subdomain': 'zulip', @@ -1595,7 +1595,7 @@ class TestDevAuthBackend(ZulipTestCase): self.assertEqual(get_session_dict_user(self.client.session), user_profile.id) def test_redirect_to_next_url(self) -> None: - def do_local_login(formaction: Text) -> HttpResponse: + def do_local_login(formaction: str) -> HttpResponse: user_email = self.example_email('hamlet') data = {'direct_email': user_email} return self.client_post(formaction, data) @@ -1791,7 +1791,7 @@ class TestZulipRemoteUserBackend(ZulipTestCase): def test_redirect_to(self) -> None: """This test verifies the behavior of the redirect_to logic in login_or_register_remote_user.""" - def test_with_redirect_to_param_set_as_next(next: Text='') -> HttpResponse: + def test_with_redirect_to_param_set_as_next(next: str='') -> HttpResponse: user_profile = self.example_user('hamlet') email = user_profile.email with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipRemoteUserBackend',)): diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index 9957699d10..6393c5abbf 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -51,7 +51,7 @@ import ujson import urllib from zerver.lib.str_utils import NonBinaryStr -from typing import Any, AnyStr, Dict, List, Optional, Set, Tuple, Text +from typing import Any, AnyStr, Dict, List, Optional, Set, Tuple class FencedBlockPreprocessorTest(TestCase): def test_simple_quoting(self) -> None: @@ -166,7 +166,7 @@ class FencedBlockPreprocessorTest(TestCase): lines = processor.run(markdown) self.assertEqual(lines, expected) -def bugdown_convert(text: Text) -> Text: +def bugdown_convert(text: str) -> str: return bugdown.convert(text, message_realm=get_realm('zulip')) class BugdownMiscTest(ZulipTestCase): @@ -179,7 +179,7 @@ class BugdownMiscTest(ZulipTestCase): def test_get_full_name_info(self) -> None: realm = get_realm('zulip') - def make_user(email: Text, full_name: Text) -> UserProfile: + def make_user(email: str, full_name: str) -> UserProfile: return create_user( email=email, password='whatever', @@ -225,15 +225,15 @@ class BugdownMiscTest(ZulipTestCase): mock_logger.assert_called_with("Cannot find KaTeX for latex rendering!") class BugdownTest(ZulipTestCase): - def assertEqual(self, first: Any, second: Any, msg: Text = "") -> None: - if isinstance(first, Text) and isinstance(second, Text): + def assertEqual(self, first: Any, second: Any, msg: str = "") -> None: + if isinstance(first, str) and isinstance(second, str): if first != second: raise AssertionError("Actual and expected outputs do not match; showing diff.\n" + mdiff.diff_strings(first, second) + msg) else: super().assertEqual(first, second) - def load_bugdown_tests(self) -> Tuple[Dict[Text, Any], List[List[Text]]]: + def load_bugdown_tests(self) -> Tuple[Dict[str, Any], List[List[str]]]: test_fixtures = {} data_file = open(os.path.join(os.path.dirname(__file__), 'fixtures/markdown_test_cases.json'), 'r') data = ujson.loads('\n'.join(data_file.readlines())) @@ -278,7 +278,7 @@ class BugdownTest(ZulipTestCase): print("Running Bugdown test %s" % (name,)) self.assertEqual(converted, test['expected_output']) - def replaced(payload: Text, url: Text, phrase: Text='') -> Text: + def replaced(payload: str, url: str, phrase: str='') -> str: target = " target=\"_blank\"" if url[:4] == 'http': href = url @@ -478,7 +478,7 @@ class BugdownTest(ZulipTestCase): self.assertEqual(bugdown.get_tweet_id('https://twitter.com/windyoona/status/410766290349879296/'), '410766290349879296') def test_inline_interesting_links(self) -> None: - def make_link(url: Text) -> Text: + def make_link(url: str) -> str: return '%s' % (url, url, url) normal_tweet_html = (':hundred_points:% open-source!""" - def make_inline_twitter_preview(url: Text, tweet_html: Text, image_html: Text='') -> Text: + def make_inline_twitter_preview(url: str, tweet_html: str, image_html: str='') -> str: ## As of right now, all previews are mocked to be the exact same tweet return ('
' '