diff options
| author | Marc Egli <frog32@me.com> | 2014-04-14 14:41:47 -0400 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2014-04-14 16:49:40 -0400 |
| commit | 0bcc92c6917738caa2f08ec16d26fad62974fb47 (patch) | |
| tree | e144e332202a3b63b623bc05716fcb522028ffb3 /tests | |
| parent | 17c18844561431aabed89c3bd48de951db7d13ab (diff) | |
Fixed #22356 -- Added a check to make sure unique_together fields are local.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/invalid_models_tests/test_models.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py index e090ade34b..1338fcabcd 100644 --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -76,6 +76,30 @@ class IndexTogetherTests(IsolatedModelsTestCase): ] self.assertEqual(errors, expected) + def test_pointing_to_non_local_field(self): + class Foo(models.Model): + field1 = models.IntegerField() + + class Bar(Foo): + field2 = models.IntegerField() + + class Meta: + index_together = [ + ["field2", "field1"], + ] + + errors = Bar.check() + expected = [ + Error( + ("'index_together' refers to field 'field1' which is not " + "local to model 'Bar'."), + hint=("This issue may be caused by multi-table inheritance."), + obj=Bar, + id='models.E016', + ), + ] + self.assertEqual(errors, expected) + def test_pointing_to_m2m_field(self): class Model(models.Model): m2m = models.ManyToManyField('self') |
