summaryrefslogtreecommitdiff
path: root/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:22:17 -0500
commitba6f83ec95dbd265ae3d493c8d6375f36052d12e (patch)
tree1912ca6010e8e771719d42c0527b391c3d304d07 /tests
parentcd46947ddb6719c819e75464d6aa0a10a6c10fad (diff)
[1.9.x] 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. Backport of 3938b3ccaa85f1c366909a4839696007726a09da from master
Diffstat (limited to '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 eb436b6a64..75cea0a4d8 100644
--- a/tests/contenttypes_tests/test_models.py
+++ b/tests/contenttypes_tests/test_models.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
import warnings
-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
@@ -170,6 +170,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):
"""