diff options
author | Carlton Gibson <carlton.gibson@noumenal.es> | 2021-06-15 11:41:50 +0200 |
---|---|---|
committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2021-06-15 11:42:52 +0200 |
commit | 0c0240aba8c769406248b5601126b891998fabb7 (patch) | |
tree | 01bd84b2985b0e058636c854e7269c97a592bec6 /tests/model_inheritance | |
parent | 316cc34d046ad86e100227772294f906fae1c2e5 (diff) | |
download | django-0c0240aba8c769406248b5601126b891998fabb7.tar.gz |
Refs #30427, Refs #16176 -- Added test for abstract model inheritance.
Diffstat (limited to 'tests/model_inheritance')
-rw-r--r-- | tests/model_inheritance/test_abstract_inheritance.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/model_inheritance/test_abstract_inheritance.py b/tests/model_inheritance/test_abstract_inheritance.py index 8caa5153fa..27b390d9f6 100644 --- a/tests/model_inheritance/test_abstract_inheritance.py +++ b/tests/model_inheritance/test_abstract_inheritance.py @@ -59,6 +59,36 @@ class AbstractInheritanceTests(SimpleTestCase): ), ]) + def test_target_field_may_be_pushed_down(self): + """ + Where the Child model needs to inherit a field from a different base + than that given by depth-first resolution, the target field can be + **pushed down** by being re-declared. + """ + + class Root(models.Model): + name = models.CharField(max_length=255) + + class Meta: + abstract = True + + class ParentA(Root): + class Meta: + abstract = True + + class ParentB(Root): + name = models.IntegerField() + + class Meta: + abstract = True + + class Child(ParentA, ParentB): + name = models.IntegerField() + + self.assertEqual(Child.check(), []) + inherited_field = Child._meta.get_field('name') + self.assertTrue(isinstance(inherited_field, models.IntegerField)) + def test_multiple_inheritance_cannot_shadow_concrete_inherited_field(self): class ConcreteParent(models.Model): name = models.CharField(max_length=255) |