mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #24483 -- Prevented keepdb from breaking with generator choices.
If Field.choices is provided as an iterator, consume it in __init__ instead of using itertools.tee (which ends up holding everything in memory anyway). Fixes a bug where deconstruct() was consuming the iterator but bypassing the call to `tee`.
This commit is contained in:
committed by
Tim Graham
parent
118cae2df8
commit
80e3444eca
@@ -445,13 +445,6 @@ class ChoicesTests(test.TestCase):
|
||||
self.assertEqual(WhizIterEmpty(c=None).c, None) # Blank value
|
||||
self.assertEqual(WhizIterEmpty(c='').c, '') # Empty value
|
||||
|
||||
def test_charfield_get_choices_with_blank_iterator(self):
|
||||
"""
|
||||
Check that get_choices works with an empty Iterator
|
||||
"""
|
||||
f = models.CharField(choices=(x for x in []))
|
||||
self.assertEqual(f.get_choices(include_blank=True), [('', '---------')])
|
||||
|
||||
|
||||
class SlugFieldTests(test.TestCase):
|
||||
def test_slugfield_max_length(self):
|
||||
|
||||
Reference in New Issue
Block a user