File: test_chain_validator.py

package info (click to toggle)
wtforms-components 0.11.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: python: 1,582; makefile: 135; sh: 11
file content (17 lines) | stat: -rw-r--r-- 520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from wtforms import Form
from wtforms.fields import StringField
from wtforms.validators import DataRequired, Email
from wtforms_test import FormTestCase

from tests import MultiDict
from wtforms_components import Chain


class TestChainValidator(FormTestCase):
    def test_validates_whole_chain(self):
        class MyForm(Form):
            email = StringField(validators=[Chain([DataRequired(), Email()])])

        form = MyForm(MultiDict({"name": ""}))
        form.validate()
        assert "email" in form.errors