Browse Source

Fixed #22993 -- Deprecated skipIfCustomUser decorator

Christopher Luc 10 years ago
parent
commit
e37d52bd5e

+ 6 - 0
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)

+ 4 - 1
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:
 

+ 6 - 0
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

+ 7 - 0
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