[Checkins] SVN: zope.configuration/trunk/ - Jython support: use __builtin__ module import rather than assuming
Chris McDonough
chrism at plope.com
Tue Jan 5 21:10:17 EST 2010
Log message for revision 107727:
- Jython support: use __builtin__ module import rather than assuming
__builtins__ is available
- Jython support: deal with the fact that the Jython SAX parser
returns attribute sets that have an empty string indicating no
namespace instead of ``None``.
- Allow ``setup.py test`` to run at least a subset of the tests that
would be run when using the zope testrunner: ``setup.py test`` runs
53 tests, while ``bin/test`` runs 156.
Changed:
U zope.configuration/trunk/CHANGES.txt
U zope.configuration/trunk/setup.py
U zope.configuration/trunk/src/zope/configuration/config.py
U zope.configuration/trunk/src/zope/configuration/xmlconfig.py
-=-
Modified: zope.configuration/trunk/CHANGES.txt
===================================================================
--- zope.configuration/trunk/CHANGES.txt 2010-01-06 01:50:37 UTC (rev 107726)
+++ zope.configuration/trunk/CHANGES.txt 2010-01-06 02:10:17 UTC (rev 107727)
@@ -5,7 +5,17 @@
3.7.1 (unreleased)
------------------
+- Jython support: use __builtin__ module import rather than assuming
+ __builtins__ is available
+- Jython support: deal with the fact that the Jython SAX parser
+ returns attribute sets that have an empty string indicating no
+ namespace instead of ``None``.
+
+- Allow ``setup.py test`` to run at least a subset of the tests that
+ would be run when using the zope testrunner: ``setup.py test`` runs
+ 53 tests, while ``bin/test`` runs 156.
+
3.7.0 (2009-12-22)
------------------
Modified: zope.configuration/trunk/setup.py
===================================================================
--- zope.configuration/trunk/setup.py 2010-01-06 01:50:37 UTC (rev 107726)
+++ zope.configuration/trunk/setup.py 2010-01-06 02:10:17 UTC (rev 107727)
@@ -26,6 +26,39 @@
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.configuration')).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())
+ return suite
+
setup(name='zope.configuration',
version = '3.7.1dev',
author='Zope Corporation and Contributors',
@@ -66,4 +99,6 @@
],
include_package_data=True,
zip_safe=False,
+ tests_require = 'zope.testing',
+ test_suite='__main__.alltests',
)
Modified: zope.configuration/trunk/src/zope/configuration/config.py
===================================================================
--- zope.configuration/trunk/src/zope/configuration/config.py 2010-01-06 01:50:37 UTC (rev 107726)
+++ zope.configuration/trunk/src/zope/configuration/config.py 2010-01-06 02:10:17 UTC (rev 107727)
@@ -18,6 +18,7 @@
$Id$
"""
__docformat__ = 'restructuredtext'
+import __builtin__
import os.path
import sys
@@ -142,7 +143,7 @@
if len(names) == 1:
# Check for built-in objects
marker = object()
- obj = __builtins__.get(names[0], marker)
+ obj = getattr(__builtin__, names[0], marker)
if obj is not marker:
return obj
Modified: zope.configuration/trunk/src/zope/configuration/xmlconfig.py
===================================================================
--- zope.configuration/trunk/src/zope/configuration/xmlconfig.py 2010-01-06 01:50:37 UTC (rev 107726)
+++ zope.configuration/trunk/src/zope/configuration/xmlconfig.py 2010-01-06 02:10:17 UTC (rev 107727)
@@ -209,7 +209,11 @@
data = {}
for (ns, aname), value in attrs.items():
- if ns is None:
+ # NB: even though on CPython, 'ns' will be ``None`` always,
+ # do not change the below to "if ns is None" because Jython's
+ # sax parser generates attrs that have empty strings for
+ # the namepace instead of ``None``.
+ if not ns:
aname = str(aname)
data[aname] = value
if (ns, aname) == ZCML_CONDITION:
More information about the checkins
mailing list