File: test_custom_fields.py

package info (click to toggle)
wtforms-alchemy 0.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 492 kB
  • sloc: python: 3,955; makefile: 119; sh: 11
file content (18 lines) | stat: -rw-r--r-- 520 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from wtforms import Form
from wtforms_components import SelectField

from tests import MultiDict
from wtforms_alchemy import null_or_unicode


class TestSelectField:
    def test_understands_none_values(self):
        class MyForm(Form):
            choice_field = SelectField(
                choices=[("", "-- Choose --"), ("choice 1", "Something")],
                coerce=null_or_unicode,
            )

        form = MyForm(MultiDict({"choice_field": ""}))
        form.validate()
        assert form.errors == {}