@@ -34,33 +34,30 @@ class DerivedGrandChild(AbstractDescendant):
3434 self .assertEqual (DerivedChild ._meta .get_field ('name' ).max_length , 50 )
3535 self .assertEqual (DerivedGrandChild ._meta .get_field ('name' ).max_length , 50 )
3636
37- def test_multiple_parents_mro (self ):
38- class AbstractBaseOne (models .Model ):
39- class Meta :
40- abstract = True
41-
42- class AbstractBaseTwo (models .Model ):
43- name = models .CharField (max_length = 30 )
44-
45- class Meta :
46- abstract = True
37+ def test_multiple_inheritance_cannot_shadow_inherited_field (self ):
38+ class ParentA (models .Model ):
39+ name = models .CharField (max_length = 255 )
4740
48- class DescendantOne (AbstractBaseOne , AbstractBaseTwo ):
4941 class Meta :
5042 abstract = True
5143
52- class DescendantTwo ( AbstractBaseOne , AbstractBaseTwo ):
53- name = models .CharField ( max_length = 50 )
44+ class ParentB ( models . Model ):
45+ name = models .IntegerField ( )
5446
5547 class Meta :
5648 abstract = True
5749
58- class Derived ( DescendantOne , DescendantTwo ):
50+ class Child ( ParentA , ParentB ):
5951 pass
6052
61- self .assertEqual (DescendantOne ._meta .get_field ('name' ).max_length , 30 )
62- self .assertEqual (DescendantTwo ._meta .get_field ('name' ).max_length , 50 )
63- self .assertEqual (Derived ._meta .get_field ('name' ).max_length , 50 )
53+ self .assertEqual (Child .check (), [
54+ Error (
55+ "The field 'name' clashes with the field 'name' from model "
56+ "'model_inheritance.child'." ,
57+ obj = Child ._meta .get_field ('name' ),
58+ id = 'models.E006' ,
59+ ),
60+ ])
6461
6562 def test_multiple_inheritance_cannot_shadow_concrete_inherited_field (self ):
6663 class ConcreteParent (models .Model ):
0 commit comments