summaryrefslogtreecommitdiff
path: root/tests/contenttypes_tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2015-11-17 00:39:28 -0500
committerSimon Charette <charette.s@gmail.com>2016-01-06 20:00:07 -0500
commita08fda2111d811aa53f11218fa03f3300dfff4cb (patch)
tree0263cf99adf17c5123b3a53c686f637d5b40eda4 /tests/contenttypes_tests
parent3096f4b0829a005c67a14cc4bb6d345aa32672a1 (diff)
Fixed #25746 -- Isolated inlined test models registration.
Thanks to Tim for the review.
Diffstat (limited to 'tests/contenttypes_tests')
-rw-r--r--tests/contenttypes_tests/tests.py24
1 files changed, 7 insertions, 17 deletions
diff --git a/tests/contenttypes_tests/tests.py b/tests/contenttypes_tests/tests.py
index dd14eaad55..e5cf3d2010 100644
--- a/tests/contenttypes_tests/tests.py
+++ b/tests/contenttypes_tests/tests.py
@@ -12,8 +12,8 @@ from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.core import checks
from django.db import connections, models
-from django.test import TestCase, override_settings
-from django.test.utils import captured_stdout
+from django.test import SimpleTestCase, TestCase, override_settings
+from django.test.utils import captured_stdout, isolate_apps
from django.utils.encoding import force_str, force_text
from .models import Article, Author, SchemeIncludedURL
@@ -114,20 +114,9 @@ class ContentTypesViewsTests(TestCase):
self.assertEqual(force_text(ct), 'modelcreatedonthefly')
-class IsolatedModelsTestCase(TestCase):
- def setUp(self):
- # The unmanaged models need to be removed after the test in order to
- # prevent bad interactions with the flush operation in other tests.
- self._old_models = apps.app_configs['contenttypes_tests'].models.copy()
-
- def tearDown(self):
- apps.app_configs['contenttypes_tests'].models = self._old_models
- apps.all_models['contenttypes_tests'] = self._old_models
- apps.clear_cache()
-
-
@override_settings(SILENCED_SYSTEM_CHECKS=['fields.W342']) # ForeignKey(unique=True)
-class GenericForeignKeyTests(IsolatedModelsTestCase):
+@isolate_apps('contenttypes_tests', attr_name='apps')
+class GenericForeignKeyTests(SimpleTestCase):
def test_str(self):
class Model(models.Model):
@@ -239,11 +228,12 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
class Model(models.Model):
content_object = MyGenericForeignKey()
- errors = checks.run_checks()
+ errors = checks.run_checks(app_configs=self.apps.get_app_configs())
self.assertEqual(errors, ['performed!'])
-class GenericRelationshipTests(IsolatedModelsTestCase):
+@isolate_apps('contenttypes_tests')
+class GenericRelationshipTests(SimpleTestCase):
def test_valid_generic_relationship(self):
class TaggedItem(models.Model):