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(DerivedChild._meta.get_field('name').max_length, 50)
|
||||||
self.assertEqual(DerivedGrandChild._meta.get_field('name').max_length, 50)
|
self.assertEqual(DerivedGrandChild._meta.get_field('name').max_length, 50)
|
||||||
|
|
||||||
def test_multiple_parents_mro(self):
|
def test_multiple_inheritance_cannot_shadow_inherited_field(self):
|
||||||
class AbstractBaseOne(models.Model):
|
class ParentA(models.Model):
|
||||||
class Meta:
|
name = models.CharField(max_length=255)
|
||||||
abstract = True
|
|
||||||
|
|
||||||
class AbstractBaseTwo(models.Model):
|
|
||||||
name = models.CharField(max_length=30)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
class DescendantOne(AbstractBaseOne, AbstractBaseTwo):
|
class ParentB(models.Model):
|
||||||
class Meta:
|
name = models.IntegerField()
|
||||||
abstract = True
|
|
||||||
|
|
||||||
class DescendantTwo(AbstractBaseOne, AbstractBaseTwo):
|
|
||||||
name = models.CharField(max_length=50)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
class Derived(DescendantOne, DescendantTwo):
|
class Child(ParentA, ParentB):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.assertEqual(DescendantOne._meta.get_field('name').max_length, 30)
|
self.assertEqual(Child.check(), [
|
||||||
self.assertEqual(DescendantTwo._meta.get_field('name').max_length, 50)
|
Error(
|
||||||
self.assertEqual(Derived._meta.get_field('name').max_length, 50)
|
"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):
|
def test_multiple_inheritance_cannot_shadow_concrete_inherited_field(self):
|
||||||
class ConcreteParent(models.Model):
|
class ConcreteParent(models.Model):
|
||||||
|
|
Loading…
Reference in New Issue