Django 1.10: Suppress logs.

This commit is contained in:
Umair Khan
2016-11-07 16:48:27 +05:00
parent 1e91b946d9
commit ee3ec96f38

View File

@@ -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):