mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-15 19:01:04 -04:00
33 lines
662 B
Python
33 lines
662 B
Python
|
|
import pytest
|
||
|
|
from wtforms import Form, StringField
|
||
|
|
|
||
|
|
from app.main.forms import StripWhitespaceForm, StripWhitespaceStringField
|
||
|
|
|
||
|
|
|
||
|
|
class ExampleForm(StripWhitespaceForm):
|
||
|
|
foo = StringField('Foo')
|
||
|
|
|
||
|
|
|
||
|
|
class ExampleFormSpecialField(Form):
|
||
|
|
foo = StripWhitespaceStringField('foo')
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize('submitted_data', [
|
||
|
|
'bar',
|
||
|
|
' bar ',
|
||
|
|
"""
|
||
|
|
\t bar
|
||
|
|
""",
|
||
|
|
' \u180E\u200B \u200C bar \u200D \u2060\uFEFF ',
|
||
|
|
])
|
||
|
|
@pytest.mark.parametrize('form', [
|
||
|
|
ExampleForm,
|
||
|
|
ExampleFormSpecialField,
|
||
|
|
])
|
||
|
|
def test_form_strips_all_whitespace(
|
||
|
|
app_,
|
||
|
|
form,
|
||
|
|
submitted_data,
|
||
|
|
):
|
||
|
|
assert form(foo=submitted_data).foo.data == 'bar'
|