File: test_validators.py

package info (click to toggle)
wtforms 3.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,064 kB
  • sloc: python: 5,264; makefile: 27; sh: 17
file content (18 lines) | stat: -rw-r--r-- 367 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import pytest

from wtforms import Form
from wtforms import StringField


@pytest.mark.parametrize("exc", [IndexError, ZeroDivisionError, ValueError])
def test_raise_exceptions(exc):
    def validate(form, field):
        raise exc

    class F(Form):
        field = StringField(validators=[validate])

    f = F()

    with pytest.raises(exc):
        f.validate()