mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Moved model_validation tests to invalid_models_tests.
This commit is contained in:
parent
8fb53c50ce
commit
02c276623d
6 changed files with 111 additions and 147 deletions
|
@ -157,6 +157,27 @@ class CharFieldTests(TestCase):
|
|||
]
|
||||
self.assertEqual(errors, expected)
|
||||
|
||||
def test_iterable_of_iterable_choices(self):
|
||||
class ThingItem(object):
|
||||
def __init__(self, value, display):
|
||||
self.value = value
|
||||
self.display = display
|
||||
|
||||
def __iter__(self):
|
||||
return (x for x in [self.value, self.display])
|
||||
|
||||
def __len__(self):
|
||||
return 2
|
||||
|
||||
class Things(object):
|
||||
def __iter__(self):
|
||||
return (x for x in [ThingItem(1, 2), ThingItem(3, 4)])
|
||||
|
||||
class ThingWithIterableChoices(models.Model):
|
||||
thing = models.CharField(max_length=100, blank=True, choices=Things())
|
||||
|
||||
self.assertEqual(ThingWithIterableChoices._meta.get_field('thing').check(), [])
|
||||
|
||||
def test_choices_containing_non_pairs(self):
|
||||
class Model(models.Model):
|
||||
field = models.CharField(max_length=10, choices=[(1, 2, 3), (1, 2, 3)])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue