Skip to content

Commit

Permalink
Test to catch formencode validators failing with genshi
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Dec 2, 2010
1 parent f7c1974 commit dbe7c1d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from tw2.core import EmptyField, IntValidator, ValidationError
from cgi import FieldStorage
import formencode
import formencode.national

import webob
if hasattr(webob, 'NestedMultiDict'):
Expand Down Expand Up @@ -599,6 +600,42 @@ class TestTableFieldset(WidgetTest):
</fieldset>"""
declarative = True

class TestTableFieldsetWithFEValidator(WidgetTest):
widget = TableFieldSet
attrs = {'field1':TextField(id='field1'),
'field2':TextField(id='field2'),
'field3':TextField(id='field3', validator=formencode.national.USPostalCode()),
}
expected = """<fieldset>
<legend></legend>
<table>
<tr class="odd" id="field1:container">
<th>Field1</th>
<td>
<input name="field1" id="field1" type="text">
<span id="field1:error"></span>
</td>
</tr><tr class="even" id="field2:container">
<th>Field2</th>
<td>
<input name="field2" id="field2" type="text">
<span id="field2:error"></span>
</td>
</tr><tr class="odd" id="field3:container">
<th>Field3</th>
<td>
<input name="field3" id="field3" type="text">
<span id="field3:error"></span>
</td>
</tr>
<tr class="error"><td colspan="2">
<span id=":error"></span>
</td></tr>
</table>
</fieldset>"""
declarative = True


class TestListFieldset(WidgetTest):
widget = ListFieldSet
attrs = {'field1':TextField(id='field1'),
Expand Down

0 comments on commit dbe7c1d

Please sign in to comment.