1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Simplified choices iterators in tests.model_fields.models.

This commit is contained in:
Sergey Fedoseev 2017-11-13 23:11:07 +05:00 committed by Tim Graham
parent 2d3cc94284
commit b5ecbf1e12

View File

@ -50,27 +50,12 @@ class Whiz(models.Model):
c = models.IntegerField(choices=CHOICES, null=True)
class Counter:
def __init__(self):
self.n = 1
def __iter__(self):
return self
def __next__(self):
if self.n > 5:
raise StopIteration
else:
self.n += 1
return (self.n, 'val-' + str(self.n))
class WhizIter(models.Model):
c = models.IntegerField(choices=Counter(), null=True)
c = models.IntegerField(choices=iter(Whiz.CHOICES), null=True)
class WhizIterEmpty(models.Model):
c = models.CharField(choices=(x for x in []), blank=True, max_length=1)
c = models.CharField(choices=iter(()), blank=True, max_length=1)
class BigD(models.Model):