From 3938b3ccaa85f1c366909a4839696007726a09da Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Fri, 18 Dec 2015 14:49:23 -0500 Subject: 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. --- tests/contenttypes_tests/test_models.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/contenttypes_tests') 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): """ -- cgit v1.3