diff options
| author | Hasan <hasan.r67@gmail.com> | 2016-01-18 12:15:45 +0330 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-01-29 13:37:33 -0500 |
| commit | 26ad01719d73823e65c0358a2ee9941e0a888a63 (patch) | |
| tree | 9e458f4c3428400e0970554ce19f6ed02e862a3b /tests/auth_tests | |
| parent | 253adc2b8a52982139d40c4f55b3fd446e1cb8f3 (diff) | |
Refs #26022 -- Replaced six.assertRaisesRegex with assertRaisesMessage as appropriate.
Diffstat (limited to 'tests/auth_tests')
| -rw-r--r-- | tests/auth_tests/test_management.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index a941847474..ab8e8a60e0 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -427,8 +427,8 @@ class CreatesuperuserManagementCommandTestCase(TestCase): self.assertEqual(u.group, group) non_existent_email = 'mymail2@gmail.com' - with self.assertRaisesMessage(CommandError, - 'email instance with email %r does not exist.' % non_existent_email): + msg = 'email instance with email %r does not exist.' % non_existent_email + with self.assertRaisesMessage(CommandError, msg): call_command( 'createsuperuser', interactive=False, @@ -670,10 +670,12 @@ class PermissionTestCase(TestCase): # check duplicated default permission Permission._meta.permissions = [ ('change_permission', 'Can edit permission (duplicate)')] - six.assertRaisesRegex(self, CommandError, + msg = ( "The permission codename 'change_permission' clashes with a " - "builtin permission for model 'auth.Permission'.", - create_permissions, auth_app_config, verbosity=0) + "builtin permission for model 'auth.Permission'." + ) + with self.assertRaisesMessage(CommandError, msg): + create_permissions(auth_app_config, verbosity=0) # check duplicated custom permissions Permission._meta.permissions = [ @@ -681,10 +683,9 @@ class PermissionTestCase(TestCase): ('other_one', 'Some other permission'), ('my_custom_permission', 'Some permission with duplicate permission code'), ] - six.assertRaisesRegex(self, CommandError, - "The permission codename 'my_custom_permission' is duplicated for model " - "'auth.Permission'.", - create_permissions, auth_app_config, verbosity=0) + msg = "The permission codename 'my_custom_permission' is duplicated for model 'auth.Permission'." + with self.assertRaisesMessage(CommandError, msg): + create_permissions(auth_app_config, verbosity=0) # should not raise anything Permission._meta.permissions = [ @@ -723,9 +724,9 @@ class PermissionTestCase(TestCase): Permission.objects.filter(content_type=permission_content_type).delete() Permission._meta.verbose_name = "some ridiculously long verbose name that is out of control" * 5 - six.assertRaisesRegex(self, exceptions.ValidationError, - "The verbose_name of auth.permission is longer than 244 characters", - create_permissions, auth_app_config, verbosity=0) + msg = "The verbose_name of auth.permission is longer than 244 characters" + with self.assertRaisesMessage(exceptions.ValidationError, msg): + create_permissions(auth_app_config, verbosity=0) def test_custom_permission_name_length(self): auth_app_config = apps.get_app_config('auth') |
