assert v.to_python(u'value (comment)') == [(u'value', u'comment')]
assert v.to_python(u'value1 (comment); value2') == [(u'value1', u'comment'), (u'value2', None)]
assert v.to_python(u'value1 (comment1); value2; value3 (comment3)') == [(u'value1', u'comment1'), (u'value2', None), ('value3', 'comment3')]
- assert v.to_python(u'value1 (comment1); value2 (test (not easy))') == [(u'value1', u'comment1'), (u'value2', u'test (not easy)')]
+ assert v.to_python(u'value1 (comment1); [[link (linkcomment)]] (not easy)') == [(u'value1', u'comment1'), (u'[[link (linkcomment)]]', u'not easy')]
def test_UrlNeinNone():
assert v.from_python(u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
+def test_MaskedEmail():
+ v = wrpylib.wrvalidators.MaskedEmail()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'abc.def@example.com') == (u'abc.def@example.com', False)
+ assert v.to_python(u'abc.def(at)example.com') == (u'abc.def@example.com', True)
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((u'abc.def@example.com', False)) == u'abc.def@example.com'
+ assert v.from_python((u'abc.def@example.com', True)) == u'abc.def(at)example.com'
+
+
def test_EmailCommentListNeinLoopNone():
v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone()
assert v.to_python(u'') == None
assert v.from_python(u'Nein') == u'Nein'
assert v.from_python(u'first@example.com') == u'first@example.com'
assert v.from_python(u'first@example.com (Nur Winter); second@example.com') == u'first@example.com (Nur Winter); second@example.com'
+ testvalue = u'abc.def(at)example.com (comment)'
+ try:
+ v.to_python(testvalue)
+ assert False
+ except formencode.Invalid:
+ pass
+ try:
+ v.from_python(testvalue)
+ assert False
+ except formencode.Invalid:
+ pass
+ v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone(allow_masked_email=True)
+ assert v.to_python(testvalue) == testvalue
+ assert v.from_python(testvalue) == testvalue
def test_GermanLift():