mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
Django 1.10: Suppress logs.
This commit is contained in:
@@ -985,16 +985,24 @@ class TestDevAuthBackend(ZulipTestCase):
|
|||||||
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.assertRaisesRegexp(Exception, 'Direct login not supported.'):
|
||||||
with mock.patch('django.core.handlers.base.logger'):
|
try:
|
||||||
self.client_post('/accounts/login/local/', data)
|
with mock.patch('django.core.handlers.exception.logger'):
|
||||||
|
self.client_post('/accounts/login/local/', data)
|
||||||
|
except ImportError:
|
||||||
|
with mock.patch('django.core.handlers.base.logger'):
|
||||||
|
self.client_post('/accounts/login/local/', data)
|
||||||
|
|
||||||
def test_login_failure_due_to_nonexistent_user(self):
|
def test_login_failure_due_to_nonexistent_user(self):
|
||||||
# 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.assertRaisesRegexp(Exception, 'User cannot login'):
|
||||||
with mock.patch('django.core.handlers.base.logger'):
|
try:
|
||||||
self.client_post('/accounts/login/local/', data)
|
with mock.patch('django.core.handlers.exception.logger'):
|
||||||
|
self.client_post('/accounts/login/local/', data)
|
||||||
|
except ImportError:
|
||||||
|
with mock.patch('django.core.handlers.base.logger'):
|
||||||
|
self.client_post('/accounts/login/local/', data)
|
||||||
|
|
||||||
class TestZulipRemoteUserBackend(ZulipTestCase):
|
class TestZulipRemoteUserBackend(ZulipTestCase):
|
||||||
def test_login_success(self):
|
def test_login_success(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user