[Checkins] SVN: z3c.form/trunk/src/z3c/form/ Make the test pass on both Python 2.4 and 2.5.

Marius Gedminas marius at pov.lt
Wed Sep 26 17:49:10 EDT 2007


Log message for revision 80145:
  Make the test pass on both Python 2.4 and 2.5.
  
  

Changed:
  U   z3c.form/trunk/src/z3c/form/action.txt
  U   z3c.form/trunk/src/z3c/form/converter.txt
  U   z3c.form/trunk/src/z3c/form/tests/test_doc.py
  U   z3c.form/trunk/src/z3c/form/validator.txt

-=-
Modified: z3c.form/trunk/src/z3c/form/action.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/action.txt	2007-09-26 21:26:25 UTC (rev 80144)
+++ z3c.form/trunk/src/z3c/form/action.txt	2007-09-26 21:49:09 UTC (rev 80145)
@@ -236,4 +236,5 @@
   <ActionErrorOccurred for <Action 'cancel' u'Cancel'>>
 
   >>> eventlog[-1].error
-  <ActionExecutionError wrapping <zope.interface.exceptions.Invalid ...>>
+  <ActionExecutionError wrapping ...Invalid...>
+

Modified: z3c.form/trunk/src/z3c/form/converter.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/converter.txt	2007-09-26 21:26:25 UTC (rev 80144)
+++ z3c.form/trunk/src/z3c/form/converter.txt	2007-09-26 21:49:09 UTC (rev 80145)
@@ -449,7 +449,7 @@
   >>> fudc.toFieldValue(myUpload) is None
   Traceback (most recent call last):
   ...
-  ValueError: (u'Bytes data is not a file object', <...AttributeError...>)
+  ValueError: (u'Bytes data is not a file object', ...AttributeError...)
 
 When the file upload widget is not used and a text-based widget is desired,
 then the regular field data converter will be chosen. Using a text widget,

Modified: z3c.form/trunk/src/z3c/form/tests/test_doc.py
===================================================================
--- z3c.form/trunk/src/z3c/form/tests/test_doc.py	2007-09-26 21:26:25 UTC (rev 80144)
+++ z3c.form/trunk/src/z3c/form/tests/test_doc.py	2007-09-26 21:49:09 UTC (rev 80145)
@@ -17,12 +17,18 @@
 """
 __docformat__ = "reStructuredText"
 import unittest
-from zope.testing import doctest
+import re
+
+from zope.testing import doctest, renormalizing
 from zope.app.testing import placelesssetup
 
 from z3c.form import testing
 
 def test_suite():
+    checker = renormalizing.RENormalizing([
+        (re.compile(r"(invalid literal for int\(\)) with base 10: '(.*)'"),
+         r'\1: \2'),
+        ])
     return unittest.TestSuite((
         doctest.DocFileSuite(
             '../action.txt',
@@ -78,6 +84,7 @@
             '../converter.txt',
             setUp=testing.setUp, tearDown=testing.tearDown,
             optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+            checker=checker,
             ),
         doctest.DocFileSuite(
             '../form.txt',

Modified: z3c.form/trunk/src/z3c/form/validator.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/validator.txt	2007-09-26 21:26:25 UTC (rev 80144)
+++ z3c.form/trunk/src/z3c/form/validator.txt	2007-09-26 21:49:09 UTC (rev 80145)
@@ -219,12 +219,10 @@
   >>> errors = invariants.validate(
   ...     {'login': u'srichter', 'email': u'strichter at foo.com'})
 
-  >>> errors
-  (<zope.interface.exceptions.Invalid instance at ...>,)
+  >>> for e in errors:
+  ...     print e.__class__.__name__ + ':', e
+  Invalid: The login not part of email.
 
-  >>> str(errors[0])
-  'The login not part of email.'
-
 Let's now have a look at writing a custom validator. In this case, we want to
 ensure that the E-mail address is at most twice as long as the login:
 
@@ -245,9 +243,11 @@
   >>> custom.validate(
   ...     {'login': u'srichter', 'email': u'srichter at foo.com'})
   ()
-  >>> custom.validate(
+  >>> errors = custom.validate(
   ...     {'login': u'srichter', 'email': u'srichter at foobar.com'})
-  (<zope.interface.exceptions.Invalid instance at ...>,)
+  >>> for e in errors:
+  ...     print e.__class__.__name__ + ':', e
+  Invalid: Email too long.
 
 To register the custom validator only for this schema, we hace to use the
 discriminator generator again.



More information about the Checkins mailing list