Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…st suite
  • Loading branch information...
commit 46789e76c68b5713795fbf71ce5fdccb727074fa 1 parent 5459795
@mjtamlyn mjtamlyn authored
View
6 tests/forms_tests/tests/tests.py
@@ -208,7 +208,8 @@ class A(models.Model):
ref = models.ForeignKey("B")
class Meta:
- model=A
+ model = A
+ fields = '__all__'
self.assertRaises(ValueError, ModelFormMetaclass, str('Form'), (ModelForm,), {'Meta': Meta})
@@ -226,7 +227,8 @@ class B(models.Model):
pass
class Meta:
- model=A
+ model = A
+ fields = '__all__'
self.assertTrue(issubclass(ModelFormMetaclass(str('Form'), (ModelForm,), {'Meta': Meta}), ModelForm))
View
5 tests/model_forms/tests.py
@@ -52,12 +52,15 @@ class Meta:
class BookForm(forms.ModelForm):
class Meta:
- model = Book
+ model = Book
+ fields = '__all__'
class DerivedBookForm(forms.ModelForm):
class Meta:
model = DerivedBook
+ fields = '__all__'
+
class ExplicitPKForm(forms.ModelForm):
View
4 tests/model_forms_regress/tests.py
@@ -97,12 +97,14 @@ class PartiallyLocalizedTripleForm(forms.ModelForm):
class Meta:
model = Triple
localized_fields = ('left', 'right',)
+ fields = '__all__'
class FullyLocalizedTripleForm(forms.ModelForm):
class Meta:
model = Triple
- localized_fields = "__all__"
+ localized_fields = '__all__'
+ fields = '__all__'
class LocalizedModelFormTest(TestCase):
def test_model_form_applies_localize_to_some_fields(self):
View
5 tests/runtests.py
@@ -5,6 +5,7 @@
import subprocess
import sys
import tempfile
+import warnings
from django import contrib
from django.utils._os import upath
@@ -107,7 +108,9 @@ def no_available_apps(self):
logger.addHandler(handler)
# Load all the ALWAYS_INSTALLED_APPS.
- get_apps()
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', 'django.contrib.comments is deprecated and will be removed before Django 1.8.', PendingDeprecationWarning)
+ get_apps()
# Load all the test model apps.
test_modules = get_test_modules()
View
14 tests/test_runner/tests.py
@@ -10,8 +10,8 @@
from django.core.management import call_command
from django import db
from django.test import runner, TransactionTestCase, skipUnlessDBFeature
-from django.test.simple import DjangoTestSuiteRunner, get_tests
from django.test.testcases import connections_support_transactions
+from django.test.utils import IgnorePendingDeprecationWarningsMixin
from django.utils import unittest
from django.utils.importlib import import_module
@@ -225,15 +225,17 @@ def test_ticket_17477(self):
self.assertNoOutput(err)
-class ModulesTestsPackages(unittest.TestCase):
+class ModulesTestsPackages(IgnorePendingDeprecationWarningsMixin, unittest.TestCase):
def test_get_tests(self):
"Check that the get_tests helper function can find tests in a directory"
+ from django.test.simple import get_tests
module = import_module(TEST_APP_OK)
tests = get_tests(module)
self.assertIsInstance(tests, type(module))
def test_import_error(self):
"Test for #12658 - Tests with ImportError's shouldn't fail silently"
+ from django.test.simple import get_tests
module = import_module(TEST_APP_ERROR)
self.assertRaises(ImportError, get_tests, module)
@@ -258,7 +260,7 @@ def test_transaction_support(self):
},
})
other = db.connections['other']
- DjangoTestSuiteRunner(verbosity=0).setup_databases()
+ runner.DiscoverRunner(verbosity=0).setup_databases()
msg = "DATABASES setting '%s' option set to sqlite3's ':memory:' value shouldn't interfere with transaction support detection." % option
# Transaction support should be properly initialised for the 'other' DB
self.assertTrue(other.features.supports_transactions, msg)
@@ -273,12 +275,12 @@ def test_setup_databases(self):
"""
Test that setup_databases() doesn't fail with dummy database backend.
"""
- runner = DjangoTestSuiteRunner(verbosity=0)
+ runner_instance = runner.DiscoverRunner(verbosity=0)
old_db_connections = db.connections
try:
db.connections = db.ConnectionHandler({})
- old_config = runner.setup_databases()
- runner.teardown_databases(old_config)
+ old_config = runner_instance.setup_databases()
+ runner_instance.teardown_databases(old_config)
except Exception as e:
self.fail("setup_databases/teardown_databases unexpectedly raised "
"an error: %s" % e)
View
5 tests/test_suite_override/tests.py
@@ -1,5 +1,5 @@
from django.db.models import get_app
-from django.test.simple import build_suite
+from django.test.utils import IgnorePendingDeprecationWarningsMixin
from django.utils import unittest
@@ -9,7 +9,7 @@ def suite():
return testSuite
-class SuiteOverrideTest(unittest.TestCase):
+class SuiteOverrideTest(IgnorePendingDeprecationWarningsMixin, unittest.TestCase):
def test_suite_override(self):
"""
Validate that you can define a custom suite when running tests with
@@ -17,6 +17,7 @@ def test_suite_override(self):
suite using ``build_suite``).
"""
+ from django.test.simple import build_suite
app = get_app("test_suite_override")
suite = build_suite(app)
self.assertEqual(suite.countTestCases(), 1)
View
6 tests/test_utils/tests.py
@@ -8,8 +8,7 @@
from django.template.loader import render_to_string
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.test.html import HTMLParseError, parse_html
-from django.test.simple import make_doctest
-from django.test.utils import CaptureQueriesContext
+from django.test.utils import CaptureQueriesContext, IgnorePendingDeprecationWarningsMixin
from django.utils import six
from django.utils import unittest
from django.utils.unittest import skip
@@ -624,9 +623,10 @@ class MyCustomField(IntegerField):
self.assertFieldOutput(MyCustomField, {}, {}, empty_value=None)
-class DoctestNormalizerTest(SimpleTestCase):
+class DoctestNormalizerTest(IgnorePendingDeprecationWarningsMixin, SimpleTestCase):
def test_normalizer(self):
+ from django.test.simple import make_doctest
suite = make_doctest("test_utils.doctest_output")
failures = unittest.TextTestRunner(stream=six.StringIO()).run(suite)
self.assertEqual(failures.failures, [])

0 comments on commit 46789e7

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