From 95b7699ffc4bdb32a504fccfd127f1b76a8a1d1c Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 15 Mar 2019 16:27:57 -0700 Subject: [PATCH] Cleaned up exception message checking in some tests. --- tests/auth_tests/test_views.py | 2 +- tests/file_uploads/tests.py | 4 ++-- tests/many_to_many/tests.py | 3 ++- tests/test_client/tests.py | 3 ++- tests/urlpatterns_reverse/tests.py | 10 +++++++--- tests/utils_tests/test_autoreload.py | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/auth_tests/test_views.py b/tests/auth_tests/test_views.py index f738a73e64..99de78e44d 100644 --- a/tests/auth_tests/test_views.py +++ b/tests/auth_tests/test_views.py @@ -854,7 +854,7 @@ class LoginRedirectAuthenticatedUser(AuthViewsTestCase): self.login() msg = ( "Redirection loop for authenticated user detected. Check that " - "your LOGIN_REDIRECT_URL doesn't point to a login page" + "your LOGIN_REDIRECT_URL doesn't point to a login page." ) with self.settings(LOGIN_REDIRECT_URL=self.do_redirect_url): with self.assertRaisesMessage(ValueError, msg): diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py index 2824b6eb42..7b31d369b2 100644 --- a/tests/file_uploads/tests.py +++ b/tests/file_uploads/tests.py @@ -385,8 +385,8 @@ class FileUploadTests(TestCase): file.write(b'a' * (2 ** 21)) file.seek(0) - # AttributeError: You cannot alter upload handlers after the upload has been processed. - with self.assertRaises(AttributeError): + msg = 'You cannot alter upload handlers after the upload has been processed.' + with self.assertRaisesMessage(AttributeError, msg): self.client.post('/quota/broken/', {'f': file}) def test_fileupload_getlist(self): diff --git a/tests/many_to_many/tests.py b/tests/many_to_many/tests.py index 098cd29e46..f0156bbe8d 100644 --- a/tests/many_to_many/tests.py +++ b/tests/many_to_many/tests.py @@ -63,7 +63,8 @@ class ManyToManyTests(TestCase): ) # Adding an object of the wrong type raises TypeError - with self.assertRaisesMessage(TypeError, "'Publication' instance expected, got