您的位置:老铁SEO > 站长新闻 > 网站交易 >

fields,用于说明如何使用wtforms.fields.Field()

文章来源:http://www.6cu.com

作者:软文外链代发

人气:12

2021-03-23 05:50:47

def test_text_area_a_wtforms_field(self):

        text_area = MaxTextAreaField('LabelText', _form=self.mock_form, _name='aName')

        self.assertIsInstance(text_area, Field)

def test_text_area_supports_maxlength_property(self):

        text_area = MaxTextAreaField('TestLabel', maxlength=20, _form=self.mock_form, _name='aName')

        self.assertIsInstance(text_area, Field)

        self.assertEqual(text_area.maxlength, 20)

def test_integer_field(self):

        integer_field = CustomIntegerField(_form=self.mock_form, _name='aName')

        self.assertIsInstance(integer_field, Field)


        try:

            integer_field.process_formdata(['NonInteger'])

        except:

            self.fail("Exceptions should not thrown by CustomIntegerField")

def test_decimal_field(self):

        decimal_field = CustomDecimalField(_form=self.mock_form, _name='aName')

        self.assertIsInstance(decimal_field, Field)


        try:

            decimal_field.process_formdata(['NonDecimal'])

        except:

            self.fail("Exception should not be thrown by CustomDecimalField")

def _init_form_helper(self, form, lock_fields):

        """General :meth:`init_form` helper utility to remove all fields

        in `lock_fields`.


        :param form: The :class:`flask_wtf.Form` instance.

        :param lock_fields: :class:`list` of field names to be removed.

        """

        for k, v in form.__dict__.items():

            if isinstance(v, Field) and not isinstance(v, HiddenField):

                if k in lock_fields:

                    del form[k]

上一篇:Spring Cloud Consul的服务注册与发现

下一篇:没有了

相关文章

在线客服

外链咨询

扫码加我微信

微信:juxia_com

返回顶部