Commits

Christoph Zwerschke committed 6c7d350

Make help(validators) work and add unit test for this (#3073626).

  • Participants
  • Parent commits c1c841f

Comments (0)

Files changed (2)

formencode/declarative.py

     def singleton(cls):
         name = '_%s__singleton' % cls.__name__
         if not hasattr(cls, name):
-            setattr(cls, name, cls(declarative_count=cls.declarative_count))
+            try:
+                setattr(cls, name, cls(declarative_count=cls.declarative_count))
+            except TypeError: # takes arguments
+                setattr(cls, name, cls)
         return getattr(cls, name)
     singleton = classmethod(singleton)
 

tests/test_validators.py

         return e.unpack_errors()
 
 
+class TestValidators(unittest.TestCase):
+
+    def testHelp(self):
+        from pydoc import text, plain
+        s = plain(text.document(validators))
+        self.assert_('Validator/Converters for use with FormEncode.' in s)
+        self.assert_('class Bool' in s)
+        self.assert_('Always Valid, returns True or False' in s)
+        self.assert_('class Email' in s)
+        self.assert_('Validate an email address.' in s)
+        self.assert_('class FieldsMatch' in s)
+        self.assert_('Tests that the given fields match' in s)
+
+
 class TestStringValidator(unittest.TestCase):
 
     def setUp(self):