From b5ecbf1e12e7d1eecebd708d1e2a73c505d69c60 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Mon, 13 Nov 2017 23:11:07 +0500 Subject: [PATCH] Simplified choices iterators in tests.model_fields.models. --- tests/model_fields/models.py | 19 ++----------------- 1 file 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):