Skip to content

Commit

Permalink
Failing test for ChoiceField eagerly evaluating choices
Browse files Browse the repository at this point in the history
  • Loading branch information
craigds committed Mar 12, 2024
1 parent 6e2a698 commit 84b3280
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django_filters.fields import (
BaseCSVField,
BaseRangeField,
ChoiceField,
DateRangeField,
DateTimeRangeField,
IsoDateTimeField,
Expand Down Expand Up @@ -58,6 +59,14 @@ def test_clean(self):
self.assertIsNone(f.clean([]))


class ChoiceFieldTests(TestCase):
def test_callable_choices_is_lazy(self):
def choices():
self.fail("choices should not be called during initialization")

ChoiceField(choices=choices)


class DateRangeFieldTests(TestCase):
def test_field(self):
f = DateRangeField()
Expand Down

0 comments on commit 84b3280

Please sign in to comment.