diff options
| author | Aron Podrigal <aronp@guaranteedplus.com> | 2015-01-30 04:40:25 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-02-09 08:37:55 -0500 |
| commit | 4d73303ee974c5f1ea6af984d4578d817825026d (patch) | |
| tree | 3964c4b670b7894a6ad01d411595a4ee3682245e /tests/invalid_models_tests | |
| parent | 981bd64dfb2854ae9d6168925ff2eb2bac273c3b (diff) | |
Fixed #24249 -- Improved field shadowing validation in model multi-inheritance.
Diffstat (limited to 'tests/invalid_models_tests')
| -rw-r--r-- | tests/invalid_models_tests/test_models.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py index 85599bc68a..f9caa3b546 100644 --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -483,6 +483,31 @@ class ShadowingFieldsTests(IsolatedModelsTestCase): ] self.assertEqual(errors, expected) + def test_multigeneration_inheritance(self): + class GrandParent(models.Model): + clash = models.IntegerField() + + class Parent(GrandParent): + pass + + class Child(Parent): + pass + + class GrandChild(Child): + clash = models.IntegerField() + + errors = GrandChild.check() + expected = [ + Error( + "The field 'clash' clashes with the field 'clash' " + "from model 'invalid_models_tests.grandparent'.", + hint=None, + obj=GrandChild._meta.get_field('clash'), + id='models.E006', + ) + ] + self.assertEqual(errors, expected) + def test_id_clash(self): class Target(models.Model): pass |
