diff --git a/django/contrib/auth/tests/auth_backends.py b/django/contrib/auth/tests/auth_backends.py index 6a99757921dee..256357a95e4a8 100644 --- a/django/contrib/auth/tests/auth_backends.py +++ b/django/contrib/auth/tests/auth_backends.py @@ -19,6 +19,10 @@ def setUp(self): def tearDown(self): settings.AUTHENTICATION_BACKENDS = self.curr_auth + # The custom_perms test messes with ContentTypes, which will + # be cached; flush the cache to ensure there are no side effects + # Refs #14975, #14925 + ContentType.objects.clear_cache() def test_has_perm(self): user = User.objects.get(username='test') @@ -174,6 +178,10 @@ def setUp(self): def tearDown(self): settings.AUTHENTICATION_BACKENDS = self.curr_auth self.restore_warnings_state() + # The get_group_permissions test messes with ContentTypes, which will + # be cached; flush the cache to ensure there are no side effects + # Refs #14975, #14925 + ContentType.objects.clear_cache() def test_has_perm(self): self.assertEqual(self.user1.has_perm('perm', TestObj()), False)