diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py index e9e8a702e0a..063c99e8bd7 100644 --- a/tests/invalid_models_tests/test_ordinary_fields.py +++ b/tests/invalid_models_tests/test_ordinary_fields.py @@ -845,6 +845,41 @@ class IntegerFieldTests(SimpleTestCase): ], ) + def test_non_iterable_choices(self): + class Model(models.Model): + field = models.IntegerField(choices=123) + + field = Model._meta.get_field("field") + self.assertEqual( + field.check(), + [ + Error( + "'choices' must be an iterable (e.g., a list or tuple).", + obj=field, + id="fields.E004", + ), + ], + ) + + def test_non_iterable_choices_number(self): + """An integer isn't a valid choice pair.""" + + class Model(models.Model): + field = models.IntegerField(choices=[123]) + + 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", + ), + ], + ) + @isolate_apps("invalid_models_tests") class TimeFieldTests(SimpleTestCase):