From 87fad5a3925c39380f79643387cdc5adde1d8863 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 15 Mar 2019 16:27:57 -0700 Subject: [PATCH] [2.2.x] Cleaned up exception message checking in some tests. Backport of 95b7699ffc4bdb32a504fccfd127f1b76a8a1d1c from master. --- 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 4949ce1bf4..e7ad1cbcdf 100644 --- a/tests/auth_tests/test_views.py +++ b/tests/auth_tests/test_views.py @@ -855,7 +855,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 fb333dcf13..ea4976dc0a 100644 --- a/tests/file_uploads/tests.py +++ b/tests/file_uploads/tests.py @@ -386,8 +386,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 933eb23a7a..71c5f92d8d 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