Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #18042 -- Advanced deprecation warnings.

Thanks Ramiro for the patch.
  • Loading branch information...
commit e84f79f05113f546810c1908c7baef99fb1e874a 1 parent 227cec6
Aymeric Augustin authored May 03, 2012

Showing 27 changed files with 75 additions and 38 deletions. Show diff stats Hide diff stats

  1. 2  django/conf/__init__.py
  2. 2  django/conf/urls/defaults.py
  3. 2  django/contrib/admin/templatetags/adminmedia.py
  4. 3  django/contrib/databrowse/__init__.py
  5. 9  django/contrib/formtools/tests/__init__.py
  6. 2  django/contrib/formtools/wizard/legacy.py
  7. 2  django/contrib/gis/utils/geoip.py
  8. 2  django/contrib/localflavor/uk/forms.py
  9. 2  django/contrib/localflavor/uk/uk_regions.py
  10. 2  django/core/cache/backends/memcached.py
  11. 4  django/core/management/__init__.py
  12. 2  django/http/__init__.py
  13. 6  django/middleware/common.py
  14. 2  django/template/defaultfilters.py
  15. 2  django/utils/copycompat.py
  16. 2  django/utils/hashcompat.py
  17. 6  django/utils/itercompat.py
  18. 4  django/utils/text.py
  19. 4  django/views/decorators/cache.py
  20. 4  django/views/decorators/csrf.py
  21. 6  tests/regressiontests/cache/tests.py
  22. 2  tests/regressiontests/decorators/tests.py
  23. 11  tests/regressiontests/logging_tests/tests.py
  24. 9  tests/regressiontests/requests/tests.py
  25. 5  tests/regressiontests/settings_tests/tests.py
  26. 14  tests/regressiontests/utils/text.py
  27. 2  tests/runtests.py
2  django/conf/__init__.py
@@ -181,7 +181,7 @@ def compat_patch_logging_config(logging_config):
181 181
             "handler: adding implicit debug-false-only filter. "
182 182
             "See http://docs.djangoproject.com/en/dev/releases/1.4/"
183 183
             "#request-exceptions-are-now-always-logged",
184  
-            PendingDeprecationWarning)
  184
+            DeprecationWarning)
185 185
 
186 186
         filter_name = "require_debug_false"
187 187
 
2  django/conf/urls/defaults.py
... ...
@@ -1,6 +1,6 @@
1 1
 import warnings
2 2
 warnings.warn("django.conf.urls.defaults is deprecated; use django.conf.urls instead",
3  
-              PendingDeprecationWarning)
  3
+              DeprecationWarning)
4 4
 
5 5
 from django.conf.urls import (handler403, handler404, handler500,
6 6
         include, patterns, url)
2  django/contrib/admin/templatetags/adminmedia.py
@@ -11,5 +11,5 @@ def admin_media_prefix():
11 11
     """
12 12
     warnings.warn(
13 13
         "The admin_media_prefix template tag is deprecated. "
14  
-        "Use the static template tag instead.", PendingDeprecationWarning)
  14
+        "Use the static template tag instead.", DeprecationWarning)
15 15
     return PrefixNode.handle_simple("ADMIN_MEDIA_PREFIX")
3  django/contrib/databrowse/__init__.py
@@ -2,5 +2,4 @@
2 2
 from django.contrib.databrowse.sites import DatabrowsePlugin, ModelDatabrowse, DatabrowseSite, site
3 3
 
4 4
 
5  
-warnings.warn("The Databrowse contrib app is deprecated",
6  
-    PendingDeprecationWarning)
  5
+warnings.warn("The Databrowse contrib app is deprecated", DeprecationWarning)
9  django/contrib/formtools/tests/__init__.py
@@ -7,6 +7,7 @@
7 7
 from django.contrib.formtools import preview, utils
8 8
 from django.contrib.formtools.wizard import FormWizard
9 9
 from django.test import TestCase
  10
+from django.test.utils import get_warnings_state, restore_warnings_state
10 11
 from django.test.utils import override_settings
11 12
 from django.utils import unittest
12 13
 
@@ -40,12 +41,20 @@ class PreviewTests(TestCase):
40 41
 
41 42
     def setUp(self):
42 43
         super(PreviewTests, self).setUp()
  44
+        self.save_warnings_state()
  45
+        warnings.filterwarnings('ignore', category=DeprecationWarning,
  46
+                                module='django.contrib.formtools.wizard.legacy')
  47
+
43 48
         # Create a FormPreview instance to share between tests
44 49
         self.preview = preview.FormPreview(TestForm)
45 50
         input_template = '<input type="hidden" name="%s" value="%s" />'
46 51
         self.input = input_template % (self.preview.unused_name('stage'), "%d")
47 52
         self.test_data = {'field1':u'foo', 'field1_':u'asdf'}
48 53
 
  54
+    def tearDown(self):
  55
+        super(PreviewTests, self).tearDown()
  56
+        self.restore_warnings_state()
  57
+
49 58
     def test_unused_name(self):
50 59
         """
51 60
         Verifies name mangling to get uniue field name.
2  django/contrib/formtools/wizard/legacy.py
@@ -39,7 +39,7 @@ def __init__(self, form_list, initial=None):
39 39
         warnings.warn(
40 40
             'Old-style form wizards have been deprecated; use the class-based '
41 41
             'views in django.contrib.formtools.wizard.views instead.',
42  
-            PendingDeprecationWarning)
  42
+            DeprecationWarning)
43 43
 
44 44
     def __repr__(self):
45 45
         return "step: %d\nform_list: %s\ninitial_data: %s" % (self.step, self.form_list, self.initial)
2  django/contrib/gis/utils/geoip.py
@@ -10,5 +10,5 @@ class GeoIP(BaseGeoIP):
10 10
         def __init__(self, *args, **kwargs):
11 11
             warnings.warn('GeoIP class has been moved to `django.contrib.gis.geoip`, and '
12 12
                           'this shortcut will disappear in Django v1.6.',
13  
-                          PendingDeprecationWarning, stacklevel=2)
  13
+                          DeprecationWarning, stacklevel=2)
14 14
             super(GeoIP, self).__init__(*args, **kwargs)
2  django/contrib/localflavor/uk/forms.py
@@ -3,7 +3,7 @@
3 3
 import warnings
4 4
 warnings.warn(
5 5
     'The "UK" prefix for United Kingdom has been deprecated in favour of the '
6  
-    'GB code. Please use the new GB-prefixed names.', PendingDeprecationWarning)
  6
+    'GB code. Please use the new GB-prefixed names.', DeprecationWarning)
7 7
 
8 8
 UKPostcodeField = forms.GBPostcodeField
9 9
 UKCountySelect = forms.GBCountySelect
2  django/contrib/localflavor/uk/uk_regions.py
@@ -6,7 +6,7 @@
6 6
 import warnings
7 7
 warnings.warn(
8 8
     'The "UK" prefix for United Kingdom has been deprecated in favour of the '
9  
-    'GB code. Please use the new GB-prefixed names.', PendingDeprecationWarning)
  9
+    'GB code. Please use the new GB-prefixed names.', DeprecationWarning)
10 10
 
11 11
 UK_NATIONS_CHOICES = GB_NATIONS_CHOICES
12 12
 UK_REGION_CHOICES  = GB_REGION_CHOICES
2  django/core/cache/backends/memcached.py
@@ -130,7 +130,7 @@ def __init__(self, server, params):
130 130
         import warnings
131 131
         warnings.warn(
132 132
             "memcached.CacheClass has been split into memcached.MemcachedCache and memcached.PyLibMCCache. Please update your cache backend setting.",
133  
-            PendingDeprecationWarning
  133
+            DeprecationWarning
134 134
         )
135 135
         try:
136 136
             import memcache
4  django/core/management/__init__.py
@@ -395,7 +395,7 @@ def setup_environ(settings_mod, original_settings_path=None):
395 395
         "you likely need to update your 'manage.py'; "
396 396
         "please see the Django 1.4 release notes "
397 397
         "(https://docs.djangoproject.com/en/dev/releases/1.4/).",
398  
-        PendingDeprecationWarning)
  398
+        DeprecationWarning)
399 399
 
400 400
     # Add this project to sys.path so that it's importable in the conventional
401 401
     # way. For example, if this file (manage.py) lives in a directory
@@ -451,7 +451,7 @@ def execute_manager(settings_mod, argv=None):
451 451
         "you likely need to update your 'manage.py'; "
452 452
         "please see the Django 1.4 release notes "
453 453
         "(https://docs.djangoproject.com/en/dev/releases/1.4/).",
454  
-        PendingDeprecationWarning)
  454
+        DeprecationWarning)
455 455
 
456 456
     setup_environ(settings_mod)
457 457
     utility = ManagementUtility(argv)
2  django/http/__init__.py
@@ -297,7 +297,7 @@ def body(self):
297 297
 
298 298
     @property
299 299
     def raw_post_data(self):
300  
-        warnings.warn('HttpRequest.raw_post_data has been deprecated. Use HttpRequest.body instead.', PendingDeprecationWarning)
  300
+        warnings.warn('HttpRequest.raw_post_data has been deprecated. Use HttpRequest.body instead.', DeprecationWarning)
301 301
         return self.body
302 302
 
303 303
     def _mark_post_parse_error(self):
6  django/middleware/common.py
@@ -130,16 +130,14 @@ def _is_ignorable_404(uri):
130 130
     if getattr(settings, 'IGNORABLE_404_STARTS', ()):
131 131
         import warnings
132 132
         warnings.warn('The IGNORABLE_404_STARTS setting has been deprecated '
133  
-                      'in favor of IGNORABLE_404_URLS.',
134  
-                      PendingDeprecationWarning)
  133
+                      'in favor of IGNORABLE_404_URLS.', DeprecationWarning)
135 134
         for start in settings.IGNORABLE_404_STARTS:
136 135
             if uri.startswith(start):
137 136
                 return True
138 137
     if getattr(settings, 'IGNORABLE_404_ENDS', ()):
139 138
         import warnings
140 139
         warnings.warn('The IGNORABLE_404_ENDS setting has been deprecated '
141  
-                      'in favor of IGNORABLE_404_URLS.',
142  
-                      PendingDeprecationWarning)
  140
+                      'in favor of IGNORABLE_404_URLS.', DeprecationWarning)
143 141
         for end in settings.IGNORABLE_404_ENDS:
144 142
             if uri.endswith(end):
145 143
                 return True
2  django/template/defaultfilters.py
@@ -53,7 +53,7 @@ def _dec(*args, **kwargs):
53 53
             warnings.warn("Setting the %s attribute of a template filter "
54 54
                           "function is deprecated; use @register.filter(%s=%s) "
55 55
                           "instead" % (attr, attr, getattr(func, attr)),
56  
-                          PendingDeprecationWarning)
  56
+                          DeprecationWarning)
57 57
             setattr(_dec, attr, getattr(func, attr))
58 58
 
59 59
     return wraps(func)(_dec)
2  django/utils/copycompat.py
@@ -7,7 +7,7 @@
7 7
 import warnings
8 8
 
9 9
 warnings.warn("django.utils.copycompat is deprecated; use the native copy module instead",
10  
-              PendingDeprecationWarning)
  10
+              DeprecationWarning)
11 11
 
12 12
 # Monkeypatch copy's deepcopy registry to handle functions correctly.
13 13
 if (hasattr(copy, '_deepcopy_dispatch') and types.FunctionType not in copy._deepcopy_dispatch):
2  django/utils/hashcompat.py
@@ -6,7 +6,7 @@
6 6
 
7 7
 import warnings
8 8
 warnings.warn("django.utils.hashcompat is deprecated; use hashlib instead",
9  
-              PendingDeprecationWarning)
  9
+              DeprecationWarning)
10 10
 
11 11
 import hashlib
12 12
 md5_constructor = hashlib.md5
6  django/utils/itercompat.py
@@ -18,18 +18,16 @@ def is_iterable(x):
18 18
         return True
19 19
 
20 20
 def product(*args, **kwds):
21  
-    # PendingDeprecationWarning in 1.5, remove this comment when the Deprecations
22  
-    # will have been advanced for 1.5
23 21
     warnings.warn("django.utils.itercompat.product is deprecated; use the native version instead",
24 22
                   PendingDeprecationWarning)
25 23
     return itertools.product(*args, **kwds)
26 24
 
27 25
 def all(iterable):
28 26
     warnings.warn("django.utils.itercompat.all is deprecated; use the native version instead",
29  
-                  PendingDeprecationWarning)
  27
+                  DeprecationWarning)
30 28
     return __builtin__.all(iterable)
31 29
 
32 30
 def any(iterable):
33 31
     warnings.warn("django.utils.itercompat.any is deprecated; use the native version instead",
34  
-                  PendingDeprecationWarning)
  32
+                  DeprecationWarning)
35 33
     return __builtin__.any(iterable)
4  django/utils/text.py
@@ -206,14 +206,14 @@ def _html_words(self, length, truncate):
206 206
 
207 207
 def truncate_words(s, num, end_text='...'):
208 208
     warnings.warn('This function has been deprecated. Use the Truncator class '
209  
-        'in django.utils.text instead.', category=PendingDeprecationWarning)
  209
+        'in django.utils.text instead.', category=DeprecationWarning)
210 210
     truncate = end_text and ' %s' % end_text or ''
211 211
     return Truncator(s).words(num, truncate=truncate)
212 212
 truncate_words = allow_lazy(truncate_words, unicode)
213 213
 
214 214
 def truncate_html_words(s, num, end_text='...'):
215 215
     warnings.warn('This function has been deprecated. Use the Truncator class '
216  
-        'in django.utils.text instead.', category=PendingDeprecationWarning)
  216
+        'in django.utils.text instead.', category=DeprecationWarning)
217 217
     truncate = end_text and ' %s' % end_text or ''
218 218
     return Truncator(s).words(num, truncate=truncate, html=True)
219 219
 truncate_html_words = allow_lazy(truncate_html_words, unicode)
4  django/views/decorators/cache.py
@@ -44,8 +44,8 @@ def warn():
44 44
         warnings.warn('The cache_page decorator must be called like: '
45 45
                       'cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). '
46 46
                       'All other ways are deprecated.',
47  
-                      PendingDeprecationWarning,
48  
-                      stacklevel=3)
  47
+                      DeprecationWarning,
  48
+                      stacklevel=2)
49 49
 
50 50
     if len(args) > 1:
51 51
         assert len(args) == 2, "cache_page accepts at most 2 arguments"
4  django/views/decorators/csrf.py
@@ -55,7 +55,7 @@ def csrf_response_exempt(view_func):
55 55
     """
56 56
     warnings.warn("csrf_response_exempt is deprecated. It no longer performs a "
57 57
                   "function, and calls to it can be removed.",
58  
-                  PendingDeprecationWarning)
  58
+                  DeprecationWarning)
59 59
     return view_func
60 60
 
61 61
 def csrf_view_exempt(view_func):
@@ -63,7 +63,7 @@ def csrf_view_exempt(view_func):
63 63
     Marks a view function as being exempt from CSRF view protection.
64 64
     """
65 65
     warnings.warn("csrf_view_exempt is deprecated. Use csrf_exempt instead.",
66  
-                  PendingDeprecationWarning)
  66
+                  DeprecationWarning)
67 67
     return csrf_exempt(view_func)
68 68
 
69 69
 def csrf_exempt(view_func):
6  tests/regressiontests/cache/tests.py
@@ -1442,12 +1442,18 @@ def hello_world_view(request, value):
1442 1442
 )
1443 1443
 class CacheMiddlewareTest(TestCase):
1444 1444
 
  1445
+    # The following tests will need to be modified in Django 1.6 to not use
  1446
+    # deprecated ways of using the cache_page decorator that will be removed in
  1447
+    # such version
1445 1448
     def setUp(self):
1446 1449
         self.factory = RequestFactory()
1447 1450
         self.default_cache = get_cache('default')
1448 1451
         self.other_cache = get_cache('other')
  1452
+        self.save_warnings_state()
  1453
+        warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.views.decorators.cache')
1449 1454
 
1450 1455
     def tearDown(self):
  1456
+        self.restore_warnings_state()
1451 1457
         self.default_cache.clear()
1452 1458
         self.other_cache.clear()
1453 1459
 
2  tests/regressiontests/decorators/tests.py
@@ -70,7 +70,7 @@ class DecoratorsTest(TestCase):
70 70
 
71 71
     def setUp(self):
72 72
         self.warning_state = get_warnings_state()
73  
-        warnings.filterwarnings('ignore', category=PendingDeprecationWarning,
  73
+        warnings.filterwarnings('ignore', category=DeprecationWarning,
74 74
                                 module='django.views.decorators.cache')
75 75
 
76 76
     def tearDown(self):
11  tests/regressiontests/logging_tests/tests.py
... ...
@@ -1,9 +1,10 @@
1 1
 import copy
  2
+import warnings
2 3
 
3 4
 from django.conf import compat_patch_logging_config
4 5
 from django.core import mail
5 6
 from django.test import TestCase, RequestFactory
6  
-from django.test.utils import override_settings
  7
+from django.test.utils import override_settings, get_warnings_state, restore_warnings_state
7 8
 from django.utils.log import CallbackFilter, RequireDebugFalse, getLogger
8 9
 
9 10
 
@@ -40,7 +41,13 @@ def test_filter_added(self):
40 41
 
41 42
         """
42 43
         config = copy.deepcopy(OLD_LOGGING)
43  
-        compat_patch_logging_config(config)
  44
+
  45
+        warnings_state = get_warnings_state()
  46
+        warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.conf')
  47
+        try:
  48
+            compat_patch_logging_config(config)
  49
+        finally:
  50
+            restore_warnings_state(warnings_state)
44 51
 
45 52
         self.assertEqual(
46 53
             config["handlers"]["mail_admins"]["filters"],
9  tests/regressiontests/requests/tests.py
@@ -420,5 +420,10 @@ def read(self, len=0):
420 420
                                'CONTENT_LENGTH': len(payload),
421 421
                                'wsgi.input': ExplodingStringIO(payload)})
422 422
 
423  
-        with self.assertRaises(UnreadablePostError):
424  
-            request.raw_post_data
  423
+        warnings_state = get_warnings_state()
  424
+        warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.http')
  425
+        try:
  426
+            with self.assertRaises(UnreadablePostError):
  427
+                request.raw_post_data
  428
+        finally:
  429
+            restore_warnings_state(warnings_state)
5  tests/regressiontests/settings_tests/tests.py
... ...
@@ -1,4 +1,5 @@
1 1
 import os
  2
+import warnings
2 3
 
3 4
 from django.conf import settings, global_settings
4 5
 from django.core.exceptions import ImproperlyConfigured
@@ -274,10 +275,14 @@ class EnvironmentVariableTest(TestCase):
274 275
     Ensures proper settings file is used in setup_environ if
275 276
     DJANGO_SETTINGS_MODULE is set in the environment.
276 277
     """
  278
+    # Decide what to do with these tests when setup_environ() gets removed in Django 1.6
277 279
     def setUp(self):
278 280
         self.original_value = os.environ.get('DJANGO_SETTINGS_MODULE')
  281
+        self.save_warnings_state()
  282
+        warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.core.management')
279 283
 
280 284
     def tearDown(self):
  285
+        self.restore_warnings_state()
281 286
         if self.original_value:
282 287
             os.environ['DJANGO_SETTINGS_MODULE'] = self.original_value
283 288
         elif 'DJANGO_SETTINGS_MODULE' in os.environ:
14  tests/regressiontests/utils/text.py
... ...
@@ -1,9 +1,19 @@
1 1
 # -*- coding: utf-8 -*-
2  
-import unittest
  2
+import warnings
3 3
 
  4
+from django.test import SimpleTestCase
4 5
 from django.utils import text
5 6
 
6  
-class TestUtilsText(unittest.TestCase):
  7
+class TestUtilsText(SimpleTestCase):
  8
+
  9
+    # In Django 1.6 truncate_words() and truncate_html_words() will be removed
  10
+    # so these tests will need to be adapted accordingly
  11
+    def setUp(self):
  12
+        self.save_warnings_state()
  13
+        warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.utils.text')
  14
+
  15
+    def tearDown(self):
  16
+        self.restore_warnings_state()
7 17
 
8 18
     def test_truncate_chars(self):
9 19
         truncator = text.Truncator(
2  tests/runtests.py
@@ -10,7 +10,7 @@
10 10
 
11 11
 # databrowse is deprecated, but we still want to run its tests
12 12
 warnings.filterwarnings('ignore', "The Databrowse contrib app is deprecated",
13  
-                        PendingDeprecationWarning, 'django.contrib.databrowse')
  13
+                        DeprecationWarning, 'django.contrib.databrowse')
14 14
 
15 15
 CONTRIB_DIR_NAME = 'django.contrib'
16 16
 MODEL_TESTS_DIR_NAME = 'modeltests'

0 notes on commit e84f79f

Please sign in to comment.
Something went wrong with that request. Please try again.