Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
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'
Exemplo n.º 3
0
 class MyForm(Form):
     a = StringField()
Exemplo n.º 4
0
 class ChildForm(Form):
     value = StringField()
Exemplo n.º 5
0
 class MyForm(Form):
     common = DateTimeField(default=datetime.datetime.today)
     specified = StringField(default=default(lambda: 'bar', 'always bar'))
     unknown = StringField(default=lambda: 'foo')
Exemplo n.º 6
0
 class MyForm(Form):
     value = StringField()
Exemplo n.º 7
0
 class GrandchildForm(Form):
     value = StringField()