Browse files

Write test to better test CompoundWidget error reporting

  • Loading branch information...
amol- committed Mar 29, 2012
1 parent 8b15822 commit 74dd87075b5e3f82ce9c9fb4768326bdf4484d8d
Showing with 12 additions and 0 deletions.
  1. +12 −0 tests/
@@ -22,6 +22,9 @@
twc.Widget(id='c', key='y', validator=formencode.validators.OpenId()),
#This is required to make tests pass on non english systems
class TestValidationError(tb.WidgetTest):
def test_validator_msg(self):
twc.core.request_local = tb.request_local_tst
@@ -142,6 +145,7 @@ class MatchyWidget(twc.CompoundWidget):
validator = formencode.validators.FieldsMatch('one', 'two')
one = twc.Widget
two = twc.Widget
three = twc.Widget(validator=twc.Validator(required=True))
MatchyWidget.validate({'one': 'foo', 'two': 'bar'})
@@ -151,6 +155,14 @@ class MatchyWidget(twc.CompoundWidget):
assert 'do not match' not in ve.widget.error_msg
assert 'childerror' not in ve.widget.error_msg
MatchyWidget.validate({'one': 'foo', 'two': 'foo', 'three':''})
assert False, "Widget should not have validated."
except ValidationError as ve:
assert 'Enter a value' in ve.widget.children[2].error_msg
assert 'Enter a value' not in ve.widget.error_msg
assert 'childerror' not in ve.widget.error_msg
def test_auto_unflatten(self):
test = twc.CompoundWidget(id='a', children=[
twc.Widget(id='b', validator=twc.Validator(required=True)),

0 comments on commit 74dd870

Please sign in to comment.