From 6c12a49d0479c1ac0f055da7bba1cb6b3bcd305c Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 4 Mar 2017 23:37:39 -0800 Subject: [PATCH] test_auth_backends: Remove now-unnecessary compatibility code. This code was added as part of the Django 1.10 migration to make our tests work with both Django 1.8 and 1.10. Now that we're on 1.10, it's no longer required. --- tools/test-backend | 1 - zerver/tests/test_auth_backends.py | 16 ++++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/tools/test-backend b/tools/test-backend index 081bf1d982..3a02ca2fb4 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -82,7 +82,6 @@ not_yet_fully_covered = { 'zerver/models.py', # Test files should have full coverage; it's a bug in the test if # they don't! - 'zerver/tests/test_auth_backends.py', 'zerver/tests/test_narrow.py', 'zerver/tests/test_tornado.py', 'zerver/tests/test_urls.py', diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index c61cfdb353..199762e3eb 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -1014,24 +1014,16 @@ class TestDevAuthBackend(ZulipTestCase): data = {'direct_email': email} with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.EmailAuthBackend',)): with self.assertRaisesRegex(Exception, 'Direct login not supported.'): - try: - 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) + with mock.patch('django.core.handlers.exception.logger'): + self.client_post('/accounts/login/local/', data) def test_login_failure_due_to_nonexistent_user(self): # type: () -> None email = 'nonexisting@zulip.com' data = {'direct_email': email} with self.assertRaisesRegex(Exception, 'User cannot login'): - try: - 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) + with mock.patch('django.core.handlers.exception.logger'): + self.client_post('/accounts/login/local/', data) class TestZulipRemoteUserBackend(ZulipTestCase): def test_login_success(self):