class MyForm(Form): short_arguments = dict(a='alpha', b='bravo', c='echo') @staticmethod def get_short_arguments(): return dict(c='charlie', d='delta') alpha = StringField() bravo = StringField() charlie = StringField() delta = StringField()
def test_metavar_kwarg(): """Check that fields accept metavar kwarg and store on the instance.""" test_types = ( DateField, DateTimeField, DecimalField, FieldList, FloatField, IntegerField, SelectField, SelectMultipleField, StringField, ) class MyForm(Form): pass for field_type in test_types: if field_type == FieldList: field = field_type(StringField(), metavar='FOO') else: field = field_type(metavar='FOO') setattr(MyForm, field_type.__name__.lower(), field) form = MyForm() for field_type in test_types: assert getattr(form, field_type.__name__.lower()).metavar == 'FOO'
class MyForm(Form): a = StringField()
class ChildForm(Form): value = StringField()
class MyForm(Form): common = DateTimeField(default=datetime.datetime.today) specified = StringField(default=default(lambda: 'bar', 'always bar')) unknown = StringField(default=lambda: 'foo')
class MyForm(Form): value = StringField()
class GrandchildForm(Form): value = StringField()