mirror of https://github.com/zulip/zulip.git
tests: s/assertRaisesRegexp/assertRaisesRegex/ due to deprecation.
This commit is contained in:
parent
6bb959ff4e
commit
bf80873d4f
|
@ -68,7 +68,7 @@ class ParserTestHappyPath(unittest.TestCase):
|
||||||
div {
|
div {
|
||||||
}'''
|
}'''
|
||||||
error = 'Empty declaration'
|
error = 'Empty declaration'
|
||||||
with self.assertRaisesRegexp(CssParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372
|
with self.assertRaisesRegex(CssParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372
|
||||||
parse(my_css)
|
parse(my_css)
|
||||||
|
|
||||||
def test_multi_line_selector(self):
|
def test_multi_line_selector(self):
|
||||||
|
@ -129,7 +129,7 @@ class ParserTestSadPath(unittest.TestCase):
|
||||||
|
|
||||||
def _assert_error(self, my_css, error):
|
def _assert_error(self, my_css, error):
|
||||||
# type: (str, str) -> None
|
# type: (str, str) -> None
|
||||||
with self.assertRaisesRegexp(CssParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372
|
with self.assertRaisesRegex(CssParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372
|
||||||
parse(my_css)
|
parse(my_css)
|
||||||
|
|
||||||
def test_unexpected_end_brace(self):
|
def test_unexpected_end_brace(self):
|
||||||
|
|
|
@ -20,7 +20,7 @@ except ImportError:
|
||||||
class ParserTest(unittest.TestCase):
|
class ParserTest(unittest.TestCase):
|
||||||
def _assert_validate_error(self, error, fn=None, text=None, check_indent=True):
|
def _assert_validate_error(self, error, fn=None, text=None, check_indent=True):
|
||||||
# type: (str, Optional[str], Optional[str], bool) -> None
|
# type: (str, Optional[str], Optional[str], bool) -> None
|
||||||
with self.assertRaisesRegexp(TemplateParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372
|
with self.assertRaisesRegex(TemplateParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372
|
||||||
validate(fn=fn, text=text, check_indent=check_indent)
|
validate(fn=fn, text=text, check_indent=check_indent)
|
||||||
|
|
||||||
def test_is_django_block_tag(self):
|
def test_is_django_block_tag(self):
|
||||||
|
|
|
@ -998,7 +998,7 @@ class TestDevAuthBackend(ZulipTestCase):
|
||||||
email = 'hamlet@zulip.com'
|
email = 'hamlet@zulip.com'
|
||||||
data = {'direct_email': email}
|
data = {'direct_email': email}
|
||||||
with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.EmailAuthBackend',)):
|
with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.EmailAuthBackend',)):
|
||||||
with self.assertRaisesRegexp(Exception, 'Direct login not supported.'):
|
with self.assertRaisesRegex(Exception, 'Direct login not supported.'):
|
||||||
try:
|
try:
|
||||||
with mock.patch('django.core.handlers.exception.logger'):
|
with mock.patch('django.core.handlers.exception.logger'):
|
||||||
self.client_post('/accounts/login/local/', data)
|
self.client_post('/accounts/login/local/', data)
|
||||||
|
@ -1010,7 +1010,7 @@ class TestDevAuthBackend(ZulipTestCase):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
email = 'nonexisting@zulip.com'
|
email = 'nonexisting@zulip.com'
|
||||||
data = {'direct_email': email}
|
data = {'direct_email': email}
|
||||||
with self.assertRaisesRegexp(Exception, 'User cannot login'):
|
with self.assertRaisesRegex(Exception, 'User cannot login'):
|
||||||
try:
|
try:
|
||||||
with mock.patch('django.core.handlers.exception.logger'):
|
with mock.patch('django.core.handlers.exception.logger'):
|
||||||
self.client_post('/accounts/login/local/', data)
|
self.client_post('/accounts/login/local/', data)
|
||||||
|
@ -1262,7 +1262,7 @@ class TestLDAP(ZulipTestCase):
|
||||||
LDAP_APPEND_DOMAIN='zulip.com',
|
LDAP_APPEND_DOMAIN='zulip.com',
|
||||||
AUTH_LDAP_BIND_PASSWORD='',
|
AUTH_LDAP_BIND_PASSWORD='',
|
||||||
AUTH_LDAP_USER_DN_TEMPLATE='uid=%(user)s,ou=users,dc=zulip,dc=com'):
|
AUTH_LDAP_USER_DN_TEMPLATE='uid=%(user)s,ou=users,dc=zulip,dc=com'):
|
||||||
with self.assertRaisesRegexp(self.mock_ldap.INVALID_CREDENTIALS,
|
with self.assertRaisesRegex(self.mock_ldap.INVALID_CREDENTIALS,
|
||||||
'uid=hamlet,ou=users,dc=zulip,dc=com:wrong'):
|
'uid=hamlet,ou=users,dc=zulip,dc=com:wrong'):
|
||||||
self.backend.authenticate('hamlet@zulip.com', 'wrong')
|
self.backend.authenticate('hamlet@zulip.com', 'wrong')
|
||||||
|
|
||||||
|
@ -1278,7 +1278,7 @@ class TestLDAP(ZulipTestCase):
|
||||||
LDAP_APPEND_DOMAIN='zulip.com',
|
LDAP_APPEND_DOMAIN='zulip.com',
|
||||||
AUTH_LDAP_BIND_PASSWORD='',
|
AUTH_LDAP_BIND_PASSWORD='',
|
||||||
AUTH_LDAP_USER_DN_TEMPLATE='uid=%(user)s,ou=users,dc=zulip,dc=com'):
|
AUTH_LDAP_USER_DN_TEMPLATE='uid=%(user)s,ou=users,dc=zulip,dc=com'):
|
||||||
with self.assertRaisesRegexp(self.mock_ldap.INVALID_CREDENTIALS,
|
with self.assertRaisesRegex(self.mock_ldap.INVALID_CREDENTIALS,
|
||||||
'uid=nonexistent,ou=users,dc=zulip,dc=com:testing'):
|
'uid=nonexistent,ou=users,dc=zulip,dc=com:testing'):
|
||||||
self.backend.authenticate('nonexistent@zulip.com', 'testing')
|
self.backend.authenticate('nonexistent@zulip.com', 'testing')
|
||||||
|
|
||||||
|
@ -1348,7 +1348,7 @@ class TestLDAP(ZulipTestCase):
|
||||||
email = 'nonexisting@zulip.com'
|
email = 'nonexisting@zulip.com'
|
||||||
realm = get_realm_by_string_id('zulip')
|
realm = get_realm_by_string_id('zulip')
|
||||||
do_deactivate_realm(realm)
|
do_deactivate_realm(realm)
|
||||||
with self.assertRaisesRegexp(Exception, 'Realm has been deactivated'):
|
with self.assertRaisesRegex(Exception, 'Realm has been deactivated'):
|
||||||
backend.get_or_create_user(email, _LDAPUser())
|
backend.get_or_create_user(email, _LDAPUser())
|
||||||
|
|
||||||
@override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',))
|
@override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',))
|
||||||
|
@ -1356,7 +1356,7 @@ class TestLDAP(ZulipTestCase):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
backend = self.backend
|
backend = self.backend
|
||||||
email = 'hamlet@zulip.com'
|
email = 'hamlet@zulip.com'
|
||||||
with self.assertRaisesRegexp(Exception, 'Username does not match LDAP domain.'):
|
with self.assertRaisesRegex(Exception, 'Username does not match LDAP domain.'):
|
||||||
with self.settings(LDAP_APPEND_DOMAIN='acme.com'):
|
with self.settings(LDAP_APPEND_DOMAIN='acme.com'):
|
||||||
backend.django_to_ldap_username(email)
|
backend.django_to_ldap_username(email)
|
||||||
|
|
||||||
|
|
|
@ -875,7 +875,7 @@ class BugdownErrorTests(ZulipTestCase):
|
||||||
|
|
||||||
message = 'whatever'
|
message = 'whatever'
|
||||||
with self.simulated_markdown_failure():
|
with self.simulated_markdown_failure():
|
||||||
# We don't use assertRaisesRegexp because it seems to not
|
# We don't use assertRaisesRegex because it seems to not
|
||||||
# handle i18n properly here on some systems.
|
# handle i18n properly here on some systems.
|
||||||
with self.assertRaises(JsonableError):
|
with self.assertRaises(JsonableError):
|
||||||
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, message)
|
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, message)
|
||||||
|
|
|
@ -192,7 +192,7 @@ class DecoratorTestCase(TestCase):
|
||||||
request.host = settings.EXTERNAL_HOST
|
request.host = settings.EXTERNAL_HOST
|
||||||
|
|
||||||
request.POST['api_key'] = 'not_existing_api_key'
|
request.POST['api_key'] = 'not_existing_api_key'
|
||||||
with self.assertRaisesRegexp(JsonableError, "Invalid API key"):
|
with self.assertRaisesRegex(JsonableError, "Invalid API key"):
|
||||||
my_webhook(request)
|
my_webhook(request)
|
||||||
|
|
||||||
# Start a valid request here
|
# Start a valid request here
|
||||||
|
@ -200,7 +200,7 @@ class DecoratorTestCase(TestCase):
|
||||||
|
|
||||||
with self.settings(REALMS_HAVE_SUBDOMAINS=True):
|
with self.settings(REALMS_HAVE_SUBDOMAINS=True):
|
||||||
with mock.patch('logging.warning') as mock_warning:
|
with mock.patch('logging.warning') as mock_warning:
|
||||||
with self.assertRaisesRegexp(JsonableError, "Account is not associated "
|
with self.assertRaisesRegex(JsonableError, "Account is not associated "
|
||||||
"with this subdomain"):
|
"with this subdomain"):
|
||||||
api_result = my_webhook(request)
|
api_result = my_webhook(request)
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ class DecoratorTestCase(TestCase):
|
||||||
"subdomain {}".format(webhook_bot_email, ''))
|
"subdomain {}".format(webhook_bot_email, ''))
|
||||||
|
|
||||||
with mock.patch('logging.warning') as mock_warning:
|
with mock.patch('logging.warning') as mock_warning:
|
||||||
with self.assertRaisesRegexp(JsonableError, "Account is not associated "
|
with self.assertRaisesRegex(JsonableError, "Account is not associated "
|
||||||
"with this subdomain"):
|
"with this subdomain"):
|
||||||
request.host = "acme." + settings.EXTERNAL_HOST
|
request.host = "acme." + settings.EXTERNAL_HOST
|
||||||
api_result = my_webhook(request)
|
api_result = my_webhook(request)
|
||||||
|
@ -236,7 +236,7 @@ class DecoratorTestCase(TestCase):
|
||||||
# Now deactivate the user
|
# Now deactivate the user
|
||||||
webhook_bot.is_active = False
|
webhook_bot.is_active = False
|
||||||
webhook_bot.save()
|
webhook_bot.save()
|
||||||
with self.assertRaisesRegexp(JsonableError, "Account not active"):
|
with self.assertRaisesRegex(JsonableError, "Account not active"):
|
||||||
my_webhook(request)
|
my_webhook(request)
|
||||||
|
|
||||||
# Reactive the user, but deactivate their realm.
|
# Reactive the user, but deactivate their realm.
|
||||||
|
@ -244,7 +244,7 @@ class DecoratorTestCase(TestCase):
|
||||||
webhook_bot.save()
|
webhook_bot.save()
|
||||||
webhook_bot.realm.deactivated = True
|
webhook_bot.realm.deactivated = True
|
||||||
webhook_bot.realm.save()
|
webhook_bot.realm.save()
|
||||||
with self.assertRaisesRegexp(JsonableError, "Realm for account has been deactivated"):
|
with self.assertRaisesRegex(JsonableError, "Realm for account has been deactivated"):
|
||||||
my_webhook(request)
|
my_webhook(request)
|
||||||
|
|
||||||
|
|
||||||
|
@ -681,7 +681,7 @@ class TestValidateApiKey(ZulipTestCase):
|
||||||
def test_valid_api_key_if_user_is_on_wrong_subdomain(self):
|
def test_valid_api_key_if_user_is_on_wrong_subdomain(self):
|
||||||
with self.settings(REALMS_HAVE_SUBDOMAINS=True):
|
with self.settings(REALMS_HAVE_SUBDOMAINS=True):
|
||||||
with mock.patch('logging.warning') as mock_warning:
|
with mock.patch('logging.warning') as mock_warning:
|
||||||
with self.assertRaisesRegexp(JsonableError, "Account is not "
|
with self.assertRaisesRegex(JsonableError, "Account is not "
|
||||||
"associated with this subdomain"):
|
"associated with this subdomain"):
|
||||||
validate_api_key(HostRequestMock(host=settings.EXTERNAL_HOST),
|
validate_api_key(HostRequestMock(host=settings.EXTERNAL_HOST),
|
||||||
self.default_bot.email,
|
self.default_bot.email,
|
||||||
|
@ -692,7 +692,7 @@ class TestValidateApiKey(ZulipTestCase):
|
||||||
"subdomain {}".format(self.default_bot.email, ''))
|
"subdomain {}".format(self.default_bot.email, ''))
|
||||||
|
|
||||||
with mock.patch('logging.warning') as mock_warning:
|
with mock.patch('logging.warning') as mock_warning:
|
||||||
with self.assertRaisesRegexp(JsonableError, "Account is not "
|
with self.assertRaisesRegex(JsonableError, "Account is not "
|
||||||
"associated with this subdomain"):
|
"associated with this subdomain"):
|
||||||
validate_api_key(HostRequestMock(host='acme.' + settings.EXTERNAL_HOST),
|
validate_api_key(HostRequestMock(host='acme.' + settings.EXTERNAL_HOST),
|
||||||
self.default_bot.email,
|
self.default_bot.email,
|
||||||
|
|
|
@ -186,7 +186,7 @@ class TestCrossRealmPMs(ZulipTestCase):
|
||||||
|
|
||||||
def assert_disallowed():
|
def assert_disallowed():
|
||||||
# type: () -> Any
|
# type: () -> Any
|
||||||
return self.assertRaisesRegexp(
|
return self.assertRaisesRegex(
|
||||||
JsonableError,
|
JsonableError,
|
||||||
'You can\'t send private messages outside of your organization.')
|
'You can\'t send private messages outside of your organization.')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue