From e37d52bd5eb98e6ddf61b766720583481d18bc2b Mon Sep 17 00:00:00 2001 From: Christopher Luc Date: Mon, 6 Apr 2015 12:02:34 -0700 Subject: [PATCH] Fixed #22993 -- Deprecated skipIfCustomUser decorator --- django/contrib/auth/tests/utils.py | 6 ++++++ docs/internals/deprecation.txt | 5 ++++- docs/releases/1.9.txt | 6 ++++++ docs/topics/auth/customizing.txt | 7 +++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/django/contrib/auth/tests/utils.py b/django/contrib/auth/tests/utils.py index 09b34156b55..ba030d632c0 100644 --- a/django/contrib/auth/tests/utils.py +++ b/django/contrib/auth/tests/utils.py @@ -1,10 +1,16 @@ +import warnings from unittest import skipIf from django.conf import settings +from django.utils.deprecation import RemovedInDjango21Warning def skipIfCustomUser(test_func): """ Skip a test if a custom user model is in use. """ + warnings.warn( + "django.contrib.auth.tests.utils.skipIfCustomUser is deprecated.", + RemovedInDjango21Warning, stacklevel=2) + return skipIf(settings.AUTH_USER_MODEL != 'auth.User', 'Custom user model in use')(test_func) diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index bb0e63dd0c9..8ffe9487bd5 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -30,7 +30,10 @@ details on these changes. * ``Field.remote_field.to`` attribute will be removed. -* ``django.db.models.fields.add_lazy_relation`` will be removed. +* ``django.db.models.fields.add_lazy_relation()`` will be removed. + +* The ``django.contrib.auth.tests.utils.skipIfCustomUser()`` decorator will be + removed. .. _deprecation-removed-in-2.0: diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index 167e016c339..cd124bf6022 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -401,6 +401,12 @@ Miscellaneous * Private API ``django.db.models.fields.add_lazy_relation()`` is deprecated. +* The ``django.contrib.auth.tests.utils.skipIfCustomUser()`` decorator is + deprecated. With the test discovery changes in Django 1.6, the tests for + ``django.contrib`` apps are no longer run as part of the user's project. + Therefore, the ``@skipIfCustomUser`` decorator is no longer needed to + decorate tests in ``django.contrib.auth``. + .. removed-features-1.9: Features removed in 1.9 diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt index e99443ff908..a3577ffb108 100644 --- a/docs/topics/auth/customizing.txt +++ b/docs/topics/auth/customizing.txt @@ -912,6 +912,13 @@ This decorator will cause a test case to be skipped if any User model other than the default Django user is in use. This decorator can be applied to a single test, or to an entire test class. +.. deprecated:: 1.9 + + With the test discovery changes in Django 1.6, the tests for + ``django.contrib`` apps are no longer run as part of the user's project. + Therefore, the ``@skipIfCustomUser`` decorator is no longer needed to + decorate tests in ``django.contrib.auth``. + Depending on your application, tests may also be needed to be added to ensure that the application works with *any* user model, not just the default User model. To assist with this, Django provides two substitute user models that