diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/invalid_models_tests/test_ordinary_fields.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py index 2c78d60924..75e6148f98 100644 --- a/tests/invalid_models_tests/test_ordinary_fields.py +++ b/tests/invalid_models_tests/test_ordinary_fields.py @@ -210,6 +210,44 @@ class CharFieldTests(TestCase): self.assertEqual(Model._meta.get_field('field').check(), []) + def test_choices_named_group_non_pairs(self): + class Model(models.Model): + field = models.CharField( + max_length=10, + choices=[['knights', [['L', 'Lancelot', 'Du Lac']]]], + ) + + field = Model._meta.get_field('field') + self.assertEqual(field.check(), [ + Error( + "'choices' must be an iterable containing (actual value, " + "human readable name) tuples.", + obj=field, + id='fields.E005', + ), + ]) + + def test_choices_named_group_bad_structure(self): + class Model(models.Model): + field = models.CharField( + max_length=10, choices=[ + ['knights', [ + ['Noble', [['G', 'Galahad']]], + ['Combative', [['L', 'Lancelot']]], + ]], + ], + ) + + field = Model._meta.get_field('field') + self.assertEqual(field.check(), [ + Error( + "'choices' must be an iterable containing (actual value, " + "human readable name) tuples.", + obj=field, + id='fields.E005', + ), + ]) + def test_bad_db_index_value(self): class Model(models.Model): field = models.CharField(max_length=10, db_index='bad') |
