[Checkins] SVN: zope.schema/trunk/ - Allow "setup.py test" to run at least a subset of the tests runnable

Chris McDonough chrism at plope.com
Tue Jan 5 12:10:47 EST 2010


Log message for revision 107713:
  - Allow "setup.py test" to run at least a subset of the tests runnable
    via ``bin/test`` (227 for ``setup.py test`` vs. 258. for
    ``bin/test``)
  
  - Make ``zope.schema._bootstrapfields.ValidatedProperty`` descriptor
    work under Jython.
  
  - Make "setup.py test" tests pass on Jython.
  
  

Changed:
  U   zope.schema/trunk/CHANGES.txt
  U   zope.schema/trunk/setup.py
  U   zope.schema/trunk/src/zope/schema/_bootstrapfields.py
  U   zope.schema/trunk/src/zope/schema/_field.py
  U   zope.schema/trunk/src/zope/schema/validation.txt

-=-
Modified: zope.schema/trunk/CHANGES.txt
===================================================================
--- zope.schema/trunk/CHANGES.txt	2010-01-05 16:34:08 UTC (rev 107712)
+++ zope.schema/trunk/CHANGES.txt	2010-01-05 17:10:46 UTC (rev 107713)
@@ -5,7 +5,15 @@
 3.6.1 (unreleased)
 ------------------
 
+- Allow "setup.py test" to run at least a subset of the tests runnable
+  via ``bin/test`` (227 for ``setup.py test`` vs. 258. for
+  ``bin/test``)
 
+- Make ``zope.schema._bootstrapfields.ValidatedProperty`` descriptor
+  work under Jython.
+
+- Make "setup.py test" tests pass on Jython.
+
 3.6.0 (2009-12-22)
 ------------------
 

Modified: zope.schema/trunk/setup.py
===================================================================
--- zope.schema/trunk/setup.py	2010-01-05 16:34:08 UTC (rev 107712)
+++ zope.schema/trunk/setup.py	2010-01-05 17:10:46 UTC (rev 107713)
@@ -26,6 +26,42 @@
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
+def _modname(path, base, name=''):
+    if path == base:
+        return name
+    dirname, basename = os.path.split(path)
+    return _modname(dirname, base, basename + '.' + name)
+
+def alltests():
+    import logging
+    import pkg_resources
+    import unittest
+
+    class NullHandler(logging.Handler):
+        level = 50
+        
+        def emit(self, record):
+            pass
+
+    logging.getLogger().addHandler(NullHandler())
+
+    suite = unittest.TestSuite()
+    base = pkg_resources.working_set.find(
+        pkg_resources.Requirement.parse('zope.schema')).location
+    for dirpath, dirnames, filenames in os.walk(base):
+        if os.path.basename(dirpath) == 'tests':
+            for filename in filenames:
+                if filename.endswith('.py') and filename.startswith('test'):
+                    mod = __import__(
+                        _modname(dirpath, base, os.path.splitext(filename)[0]),
+                        {}, {}, ['*'])
+                    suite.addTest(mod.test_suite())
+        elif 'tests.py' in filenames:
+            continue
+            mod = __import__(_modname(dirpath, base, 'tests'), {}, {}, ['*'])
+            suite.addTest(mod.test_suite())
+    return suite
+
 setup(name='zope.schema',
       version = '3.6.1dev',
       url='http://pypi.python.org/pypi/zope.schema',
@@ -54,4 +90,5 @@
                        ],
       include_package_data = True,
       zip_safe = False,
+      test_suite='__main__.alltests',
       )

Modified: zope.schema/trunk/src/zope/schema/_bootstrapfields.py
===================================================================
--- zope.schema/trunk/src/zope/schema/_bootstrapfields.py	2010-01-05 16:34:08 UTC (rev 107712)
+++ zope.schema/trunk/src/zope/schema/_bootstrapfields.py	2010-01-05 17:10:46 UTC (rev 107713)
@@ -16,6 +16,9 @@
 $Id$
 """
 __docformat__ = 'restructuredtext'
+
+import sys
+
 from zope.interface import Attribute, providedBy, implements
 from zope.schema._bootstrapinterfaces import StopValidation
 from zope.schema._bootstrapinterfaces import IFromUnicode
@@ -43,7 +46,13 @@
                 inst.validate(value)
         inst.__dict__[name] = value
 
+    if sys.platform.startswith('java'):
+        # apparently descriptors work differently on Jython
+        def __get__(self, inst, owner):
+            name, check = self._info
+            return inst.__dict__[name]
 
+
 class Field(Attribute):
 
     # Type restrictions, if any
@@ -390,7 +399,7 @@
         >>> f = Int()
         >>> f.fromUnicode("125")
         125
-        >>> f.fromUnicode("125.6")
+        >>> f.fromUnicode("125.6") #doctest: +IGNORE_EXCEPTION_DETAIL
         Traceback (most recent call last):
         ...
         ValueError: invalid literal for int(): 125.6

Modified: zope.schema/trunk/src/zope/schema/_field.py
===================================================================
--- zope.schema/trunk/src/zope/schema/_field.py	2010-01-05 16:34:08 UTC (rev 107712)
+++ zope.schema/trunk/src/zope/schema/_field.py	2010-01-05 17:10:46 UTC (rev 107713)
@@ -167,8 +167,8 @@
         >>> f = Float()
         >>> f.fromUnicode("1.25")
         1.25
-        >>> f.fromUnicode("1.25.6")
-        Traceback (most recent call last):
+        >>> f.fromUnicode("1.25.6") #doctest: +IGNORE_EXCEPTION_DETAIL
+        Traceback (most recent call last): 
         ...
         ValueError: invalid literal for float(): 1.25.6
         """

Modified: zope.schema/trunk/src/zope/schema/validation.txt
===================================================================
--- zope.schema/trunk/src/zope/schema/validation.txt	2010-01-05 16:34:08 UTC (rev 107712)
+++ zope.schema/trunk/src/zope/schema/validation.txt	2010-01-05 17:10:46 UTC (rev 107713)
@@ -36,6 +36,7 @@
 
   >>> ti = TwoInts()
   >>> r = zope.schema.getValidationErrors(ITwoInts, ti)
+  >>> r.sort()
   >>> r
   [('a', SchemaNotFullyImplemented(...AttributeError...)),
    ('b', SchemaNotFullyImplemented(...AttributeError...))]
@@ -47,6 +48,7 @@
 The `getSchemaValidationErrors` function returns the same result:
 
   >>> r = zope.schema.getSchemaValidationErrors(ITwoInts, ti)
+  >>> r.sort()
   >>> r
   [('a', SchemaNotFullyImplemented(...AttributeError...)),
    ('b', SchemaNotFullyImplemented(...AttributeError...))]
@@ -62,6 +64,7 @@
 
   >>> ti.a = 11
   >>> errors = zope.schema.getValidationErrors(ITwoInts, ti)
+  >>> errors.sort()
   >>> errors
   [('a', TooBig(11, 10)),
    ('b', SchemaNotFullyImplemented(...AttributeError...))]



More information about the checkins mailing list