summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-11-13 23:11:07 +0500
committerTim Graham <timograham@gmail.com>2017-11-13 13:11:07 -0500
commitb5ecbf1e12e7d1eecebd708d1e2a73c505d69c60 (patch)
tree2e80fe70171abb4bc3ab7bac8dd569d9c716641a /tests/model_fields
parent2d3cc94284674638c334670903d49565039d77ae (diff)
Simplified choices iterators in tests.model_fields.models.
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/models.py19
1 files changed, 2 insertions, 17 deletions
diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py
index 1d18e78869..1996011512 100644
--- a/tests/model_fields/models.py
+++ b/tests/model_fields/models.py
@@ -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):