File: test_string.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-- 520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from tests.common import DummyPostData
from wtforms.fields import StringField
from wtforms.form import Form


class F(Form):
    a = StringField()


def test_string_field():
    form = F()
    assert form.a.data is None
    assert form.a() == """<input id="a" name="a" type="text" value="">"""
    form = F(DummyPostData(a=["hello"]))
    assert form.a.data == "hello"
    assert form.a() == """<input id="a" name="a" type="text" value="hello">"""
    form = F(DummyPostData(b=["hello"]))
    assert form.a.data is None