Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Nov 29, 2023
1 parent 0f7c052 commit 2efb900
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions cms/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from cms.forms.validators import validate_url
from cms.forms.widgets import PageSelectWidget, PageSmartLinkWidget
from cms.models.pagemodel import Page
from cms.utils.compat import DJANGO_4_2


class SuperLazyIterator():
Expand Down
13 changes: 13 additions & 0 deletions cms/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ def test_superlazy_iterator_behaves_properly_for_pages(self):

self.assertEqual(normal_result, list(lazy_result))

def test_lazy_choice_field_behaves_properly(self):
"""Ensure LazyChoiceField is really lazy"""
choices_called = False
def get_choices():
nonlocal choices_called
choices_called = True
return ("", "-----"),

LazyChoiceField(
choices=get_choices
)
self.assertFalse(choices_called)


class PermissionFormTestCase(CMSTestCase):

Expand Down

0 comments on commit 2efb900

Please sign in to comment.