[Checkins] SVN: Sandbox/ulif/grokcore.startup/src/grokcore/startup/tests/test_grokcorestartup.py Copy testsetup from grokcore.component into our package.

Uli Fouquet uli at gnufix.de
Sun Feb 1 10:25:02 EST 2009


Log message for revision 95859:
  Copy testsetup from grokcore.component into our package.

Changed:
  A   Sandbox/ulif/grokcore.startup/src/grokcore/startup/tests/test_grokcorestartup.py

-=-
Copied: Sandbox/ulif/grokcore.startup/src/grokcore/startup/tests/test_grokcorestartup.py (from rev 95858, grokcore.component/trunk/src/grokcore/component/tests/test_grok.py)
===================================================================
--- Sandbox/ulif/grokcore.startup/src/grokcore/startup/tests/test_grokcorestartup.py	                        (rev 0)
+++ Sandbox/ulif/grokcore.startup/src/grokcore/startup/tests/test_grokcorestartup.py	2009-02-01 15:25:01 UTC (rev 95859)
@@ -0,0 +1,64 @@
+import re
+import unittest, traceback
+from pkg_resources import resource_listdir
+from zope.testing import doctest, cleanup, renormalizing
+import zope.component.eventtesting
+
+def setUpZope(test):
+    zope.component.eventtesting.setUp(test)
+
+def cleanUpZope(test):
+    cleanup.cleanUp()
+
+checker = renormalizing.RENormalizing([
+    # str(Exception) has changed from Python 2.4 to 2.5 (due to
+    # Exception now being a new-style class).  This changes the way
+    # exceptions appear in traceback printouts.
+    (re.compile(r"ConfigurationExecutionError: <class '([\w.]+)'>:"),
+                r'ConfigurationExecutionError: \1:'),
+    ])
+
+def suiteFromPackage(name):
+    files = resource_listdir(__name__, name)
+    suite = unittest.TestSuite()
+    for filename in files:
+        if not filename.endswith('.py'):
+            continue
+        if filename.endswith('_fixture.py'):
+            continue
+        if filename == '__init__.py':
+            continue
+
+        dottedname = 'grokcore.component.tests.%s.%s' % (name, filename[:-3])
+        try:
+            test = doctest.DocTestSuite(dottedname,
+                                        setUp=setUpZope,
+                                        tearDown=cleanUpZope,
+                                        checker=checker,
+                                        optionflags=doctest.ELLIPSIS+
+                                        doctest.NORMALIZE_WHITESPACE)
+        except ImportError, e:  # or should this accept anything?
+            traceback.print_exc()
+            raise
+        suite.addTest(test)
+    return suite
+
+def test_suite():
+    suite = unittest.TestSuite()
+    for name in ['adapter', 'directive', 'grokker', 'utility', 'view',
+                 'event']:
+        suite.addTest(suiteFromPackage(name))
+
+    api = doctest.DocFileSuite('api.txt')
+    suite.addTest(api)
+
+    # this test cannot follow the normal testing pattern, as the
+    # bug it tests for is only exposed in the context of a doctest
+    grok_component = doctest.DocFileSuite('grok_component.txt',
+                                          setUp=setUpZope,
+                                          tearDown=cleanUpZope)
+    suite.addTest(grok_component)
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')



More information about the Checkins mailing list