File: test_disabled.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 (20 lines) | stat: -rw-r--r-- 550 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from tests.common import DummyPostData
from wtforms import Form
from wtforms import StringField
from wtforms.validators import Disabled


def test_disabled():
    class F(Form):
        disabled = StringField(validators=[Disabled()])

    form = F(disabled="foobar")
    assert "disabled" in form.disabled.flags
    assert (
        form.disabled()
        == '<input disabled id="disabled" name="disabled" type="text" value="foobar">'
    )
    assert form.validate()

    form = F(DummyPostData(disabled=["foobar"]))
    assert not form.validate()