summaryrefslogtreecommitdiff
path: root/tests/contenttypes_tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2015-12-18 14:49:23 -0500
committerSimon Charette <charette.s@gmail.com>2016-02-26 16:18:16 -0500
commit3938b3ccaa85f1c366909a4839696007726a09da (patch)
tree77bb489477f60168b61add15522aa7479f30fbae /tests/contenttypes_tests
parentb9519b273030a12f382ea0c1b72729fc0c3248da (diff)
Fixed #26286 -- Prevented content type managers from sharing their cache.
This should prevent managers methods from returning content type instances registered to foreign apps now that these managers are also attached to models created during migration phases. Thanks Tim for the review. Refs #23822.
Diffstat (limited to 'tests/contenttypes_tests')
-rw-r--r--tests/contenttypes_tests/test_models.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/contenttypes_tests/test_models.py b/tests/contenttypes_tests/test_models.py
index 12010ac781..7644a8ea30 100644
--- a/tests/contenttypes_tests/test_models.py
+++ b/tests/contenttypes_tests/test_models.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-from django.contrib.contenttypes.models import ContentType
+from django.contrib.contenttypes.models import ContentType, ContentTypeManager
from django.contrib.contenttypes.views import shortcut
from django.contrib.sites.shortcuts import get_current_site
from django.db.utils import IntegrityError, OperationalError, ProgrammingError
@@ -168,6 +168,18 @@ class ContentTypesTests(TestCase):
DeferredProxyModel: proxy_model_ct,
})
+ def test_cache_not_shared_between_managers(self):
+ with self.assertNumQueries(1):
+ ContentType.objects.get_for_model(ContentType)
+ with self.assertNumQueries(0):
+ ContentType.objects.get_for_model(ContentType)
+ other_manager = ContentTypeManager()
+ other_manager.model = ContentType
+ with self.assertNumQueries(1):
+ other_manager.get_for_model(ContentType)
+ with self.assertNumQueries(0):
+ other_manager.get_for_model(ContentType)
+
@override_settings(ALLOWED_HOSTS=['example.com'])
def test_shortcut_view(self):
"""