from unittest import TestCase
from django import forms
def callback():
print("callback")
return [('foo', 'bar')]
class MyForm(forms.Form):
f = forms.ChoiceField(choices=callback)
class FormTest(TestCase):
MyForm().as_p()
./manage.py test spi.test_f
callback
callback
System check identified no issues (0 silenced).
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK