mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #31437 -- Corrected tests to show abstract multiple inheritance system check error.
Added minimal multiple inheritance test case showing error.
Removed obsolete diamond-inheritance case, originally added in
85ef98dc6e
.
This commit is contained in:
parent
537b0c5edf
commit
4bbe8261c4
@ -34,33 +34,30 @@ class AbstractInheritanceTests(SimpleTestCase):
|
||||
self.assertEqual(DerivedChild._meta.get_field('name').max_length, 50)
|
||||
self.assertEqual(DerivedGrandChild._meta.get_field('name').max_length, 50)
|
||||
|
||||
def test_multiple_parents_mro(self):
|
||||
class AbstractBaseOne(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class AbstractBaseTwo(models.Model):
|
||||
name = models.CharField(max_length=30)
|
||||
def test_multiple_inheritance_cannot_shadow_inherited_field(self):
|
||||
class ParentA(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class DescendantOne(AbstractBaseOne, AbstractBaseTwo):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class DescendantTwo(AbstractBaseOne, AbstractBaseTwo):
|
||||
name = models.CharField(max_length=50)
|
||||
class ParentB(models.Model):
|
||||
name = models.IntegerField()
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class Derived(DescendantOne, DescendantTwo):
|
||||
class Child(ParentA, ParentB):
|
||||
pass
|
||||
|
||||
self.assertEqual(DescendantOne._meta.get_field('name').max_length, 30)
|
||||
self.assertEqual(DescendantTwo._meta.get_field('name').max_length, 50)
|
||||
self.assertEqual(Derived._meta.get_field('name').max_length, 50)
|
||||
self.assertEqual(Child.check(), [
|
||||
Error(
|
||||
"The field 'name' clashes with the field 'name' from model "
|
||||
"'model_inheritance.child'.",
|
||||
obj=Child._meta.get_field('name'),
|
||||
id='models.E006',
|
||||
),
|
||||
])
|
||||
|
||||
def test_multiple_inheritance_cannot_shadow_concrete_inherited_field(self):
|
||||
class ConcreteParent(models.Model):
|
||||
|
Loading…
Reference in New Issue
Block a user