From c31bf8cb54e591e244abc951896ef5e4a089f38d Mon Sep 17 00:00:00 2001 From: Andriy Sokolovskiy Date: Thu, 18 Jun 2015 17:13:04 +0300 Subject: [PATCH] Refs #20203 -- Added tests to check inherited custom default manager --- tests/custom_managers/models.py | 12 ++++++++++++ tests/custom_managers/tests.py | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/custom_managers/models.py b/tests/custom_managers/models.py index 0444d40f58..318059a037 100644 --- a/tests/custom_managers/models.py +++ b/tests/custom_managers/models.py @@ -194,3 +194,15 @@ class OneToOneRestrictedModel(models.Model): def __str__(self): return self.name + + +class AbstractPerson(models.Model): + abstract_persons = models.Manager() + objects = models.CharField(max_length=30) + + class Meta: + abstract = True + + +class PersonFromAbstract(AbstractPerson): + pass diff --git a/tests/custom_managers/tests.py b/tests/custom_managers/tests.py index 7dc5552e41..0412a423aa 100644 --- a/tests/custom_managers/tests.py +++ b/tests/custom_managers/tests.py @@ -6,8 +6,8 @@ from django.utils import six from .models import ( Book, Car, CustomManager, CustomQuerySet, DeconstructibleCustomManager, - FunPerson, OneToOneRestrictedModel, Person, PersonManager, - PublishedBookManager, RelatedModel, RestrictedModel, + FunPerson, OneToOneRestrictedModel, Person, PersonFromAbstract, + PersonManager, PublishedBookManager, RelatedModel, RestrictedModel, ) @@ -512,6 +512,17 @@ class CustomManagerTests(TestCase): with self.assertRaisesMessage(ValueError, msg): mgr.deconstruct() + def test_abstract_model_with_custom_manager_name(self): + """ + A custom manager may be defined on an abstract model. + It will be inherited by the abstract model's children. + """ + PersonFromAbstract.abstract_persons.create(objects='Test') + self.assertQuerysetEqual( + PersonFromAbstract.abstract_persons.all(), ["Test"], + lambda c: c.objects, + ) + class TestCars(TestCase):