Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #20548 -- Removed all PendingDeprecationWarnings from django te…

…st suite
  • Loading branch information...
commit 46789e76c68b5713795fbf71ce5fdccb727074fa 1 parent 5459795
Marc Tamlyn authored June 14, 2013
6  tests/forms_tests/tests/tests.py
@@ -208,7 +208,8 @@ class A(models.Model):
208 208
             ref = models.ForeignKey("B")
209 209
 
210 210
         class Meta:
211  
-            model=A
  211
+            model = A
  212
+            fields = '__all__'
212 213
 
213 214
         self.assertRaises(ValueError, ModelFormMetaclass, str('Form'), (ModelForm,), {'Meta': Meta})
214 215
 
@@ -226,7 +227,8 @@ class B(models.Model):
226 227
             pass
227 228
 
228 229
         class Meta:
229  
-            model=A
  230
+            model = A
  231
+            fields = '__all__'
230 232
 
231 233
         self.assertTrue(issubclass(ModelFormMetaclass(str('Form'), (ModelForm,), {'Meta': Meta}), ModelForm))
232 234
 
5  tests/model_forms/tests.py
@@ -52,12 +52,15 @@ class Meta:
52 52
 
53 53
 class BookForm(forms.ModelForm):
54 54
     class Meta:
55  
-       model = Book
  55
+        model = Book
  56
+        fields = '__all__'
56 57
 
57 58
 
58 59
 class DerivedBookForm(forms.ModelForm):
59 60
     class Meta:
60 61
         model = DerivedBook
  62
+        fields = '__all__'
  63
+
61 64
 
62 65
 
63 66
 class ExplicitPKForm(forms.ModelForm):
4  tests/model_forms_regress/tests.py
@@ -97,12 +97,14 @@ class PartiallyLocalizedTripleForm(forms.ModelForm):
97 97
     class Meta:
98 98
         model = Triple
99 99
         localized_fields = ('left', 'right',)
  100
+        fields = '__all__'
100 101
 
101 102
 
102 103
 class FullyLocalizedTripleForm(forms.ModelForm):
103 104
     class Meta:
104 105
         model = Triple
105  
-        localized_fields = "__all__"
  106
+        localized_fields = '__all__'
  107
+        fields = '__all__'
106 108
 
107 109
 class LocalizedModelFormTest(TestCase):
108 110
     def test_model_form_applies_localize_to_some_fields(self):
5  tests/runtests.py
@@ -5,6 +5,7 @@
5 5
 import subprocess
6 6
 import sys
7 7
 import tempfile
  8
+import warnings
8 9
 
9 10
 from django import contrib
10 11
 from django.utils._os import upath
@@ -107,7 +108,9 @@ def no_available_apps(self):
107 108
         logger.addHandler(handler)
108 109
 
109 110
     # Load all the ALWAYS_INSTALLED_APPS.
110  
-    get_apps()
  111
+    with warnings.catch_warnings():
  112
+        warnings.filterwarnings('ignore', 'django.contrib.comments is deprecated and will be removed before Django 1.8.', PendingDeprecationWarning)
  113
+        get_apps()
111 114
 
112 115
     # Load all the test model apps.
113 116
     test_modules = get_test_modules()
14  tests/test_runner/tests.py
@@ -10,8 +10,8 @@
10 10
 from django.core.management import call_command
11 11
 from django import db
12 12
 from django.test import runner, TransactionTestCase, skipUnlessDBFeature
13  
-from django.test.simple import DjangoTestSuiteRunner, get_tests
14 13
 from django.test.testcases import connections_support_transactions
  14
+from django.test.utils import IgnorePendingDeprecationWarningsMixin
15 15
 from django.utils import unittest
16 16
 from django.utils.importlib import import_module
17 17
 
@@ -225,15 +225,17 @@ def test_ticket_17477(self):
225 225
         self.assertNoOutput(err)
226 226
 
227 227
 
228  
-class ModulesTestsPackages(unittest.TestCase):
  228
+class ModulesTestsPackages(IgnorePendingDeprecationWarningsMixin, unittest.TestCase):
229 229
     def test_get_tests(self):
230 230
         "Check that the get_tests helper function can find tests in a directory"
  231
+        from django.test.simple import get_tests
231 232
         module = import_module(TEST_APP_OK)
232 233
         tests = get_tests(module)
233 234
         self.assertIsInstance(tests, type(module))
234 235
 
235 236
     def test_import_error(self):
236 237
         "Test for #12658 - Tests with ImportError's shouldn't fail silently"
  238
+        from django.test.simple import get_tests
237 239
         module = import_module(TEST_APP_ERROR)
238 240
         self.assertRaises(ImportError, get_tests, module)
239 241
 
@@ -258,7 +260,7 @@ def test_transaction_support(self):
258 260
                     },
259 261
                 })
260 262
                 other = db.connections['other']
261  
-                DjangoTestSuiteRunner(verbosity=0).setup_databases()
  263
+                runner.DiscoverRunner(verbosity=0).setup_databases()
262 264
                 msg = "DATABASES setting '%s' option set to sqlite3's ':memory:' value shouldn't interfere with transaction support detection." % option
263 265
                 # Transaction support should be properly initialised for the 'other' DB
264 266
                 self.assertTrue(other.features.supports_transactions, msg)
@@ -273,12 +275,12 @@ def test_setup_databases(self):
273 275
         """
274 276
         Test that setup_databases() doesn't fail with dummy database backend.
275 277
         """
276  
-        runner = DjangoTestSuiteRunner(verbosity=0)
  278
+        runner_instance = runner.DiscoverRunner(verbosity=0)
277 279
         old_db_connections = db.connections
278 280
         try:
279 281
             db.connections = db.ConnectionHandler({})
280  
-            old_config = runner.setup_databases()
281  
-            runner.teardown_databases(old_config)
  282
+            old_config = runner_instance.setup_databases()
  283
+            runner_instance.teardown_databases(old_config)
282 284
         except Exception as e:
283 285
             self.fail("setup_databases/teardown_databases unexpectedly raised "
284 286
                       "an error: %s" % e)
5  tests/test_suite_override/tests.py
... ...
@@ -1,5 +1,5 @@
1 1
 from django.db.models import get_app
2  
-from django.test.simple import build_suite
  2
+from django.test.utils import IgnorePendingDeprecationWarningsMixin
3 3
 from django.utils import unittest
4 4
 
5 5
 
@@ -9,7 +9,7 @@ def suite():
9 9
     return testSuite
10 10
 
11 11
 
12  
-class SuiteOverrideTest(unittest.TestCase):
  12
+class SuiteOverrideTest(IgnorePendingDeprecationWarningsMixin, unittest.TestCase):
13 13
     def test_suite_override(self):
14 14
         """
15 15
         Validate that you can define a custom suite when running tests with
@@ -17,6 +17,7 @@ def test_suite_override(self):
17 17
         suite using ``build_suite``).
18 18
         """
19 19
 
  20
+        from django.test.simple import build_suite
20 21
         app = get_app("test_suite_override")
21 22
         suite = build_suite(app)
22 23
         self.assertEqual(suite.countTestCases(), 1)
6  tests/test_utils/tests.py
@@ -8,8 +8,7 @@
8 8
 from django.template.loader import render_to_string
9 9
 from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
10 10
 from django.test.html import HTMLParseError, parse_html
11  
-from django.test.simple import make_doctest
12  
-from django.test.utils import CaptureQueriesContext
  11
+from django.test.utils import CaptureQueriesContext, IgnorePendingDeprecationWarningsMixin
13 12
 from django.utils import six
14 13
 from django.utils import unittest
15 14
 from django.utils.unittest import skip
@@ -624,9 +623,10 @@ class MyCustomField(IntegerField):
624 623
         self.assertFieldOutput(MyCustomField, {}, {}, empty_value=None)
625 624
 
626 625
 
627  
-class DoctestNormalizerTest(SimpleTestCase):
  626
+class DoctestNormalizerTest(IgnorePendingDeprecationWarningsMixin, SimpleTestCase):
628 627
 
629 628
     def test_normalizer(self):
  629
+        from django.test.simple import make_doctest
630 630
         suite = make_doctest("test_utils.doctest_output")
631 631
         failures = unittest.TextTestRunner(stream=six.StringIO()).run(suite)
632 632
         self.assertEqual(failures.failures, [])

0 notes on commit 46789e7

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