[Checkins] SVN: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/ Move testing to doctesting.

Uli Fouquet uli at gnufix.de
Sat Feb 2 10:52:49 EST 2008


Log message for revision 83427:
  Move testing to doctesting.

Changed:
  U   Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/__init__.py
  A   Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/doctesting.py
  D   Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testing.py

-=-
Modified: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/__init__.py
===================================================================
--- Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/__init__.py	2008-02-02 15:45:54 UTC (rev 83426)
+++ Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/__init__.py	2008-02-02 15:52:49 UTC (rev 83427)
@@ -1,3 +1,3 @@
-from z3c.testsetup.testing import (UnitDocTestSetup, FunctionalDocTestSetup,
-                                   register_doctests)
+from z3c.testsetup.doctesting import (UnitDocTestSetup, FunctionalDocTestSetup,
+                                      register_doctests)
 from z3c.testsetup.base import BasicTestSetup

Copied: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/doctesting.py (from rev 83417, Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testing.py)
===================================================================
--- Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/doctesting.py	                        (rev 0)
+++ Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/doctesting.py	2008-02-02 15:52:49 UTC (rev 83427)
@@ -0,0 +1,156 @@
+##############################################################################
+#
+# Copyright (c) 2007-2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Test setup helpers for doctests.
+"""
+import unittest
+import os.path
+from zope.testing import doctest, cleanup
+from zope.app.testing.functional import (
+    HTTPCaller, getRootFolder, sync, ZCMLLayer, FunctionalDocFileSuite,
+    FunctionalTestSetup)
+from z3c.testsetup.base import BasicTestSetup
+from z3c.testsetup.util import get_package
+
+class UnitDocTestSetup(BasicTestSetup):
+    """A unit test setup for packages.
+
+    A collection of methods to search for appropriate doctest files in
+    a given package. ``UnitTestSetup`` is also able to 'register' the
+    tests found and to deliver them as a ready-to-use
+    ``unittest.TestSuite`` instance.
+
+    While the functionality to search for testfiles is mostly
+    inherited from the base class, the focus here is to setup the
+    tests correctly.
+
+    See file `unittestsetup.py` in the tests/testsetup directory to
+    learn more about ``UnitTestSetup``.
+    """
+
+    optionflags = (doctest.ELLIPSIS+
+                   doctest.NORMALIZE_WHITESPACE+
+                   doctest.REPORT_NDIFF)
+
+    regexp_list = [
+        '^\s*:(T|t)est-(L|l)ayer:\s*(unit)\s*',
+        ]
+
+
+    def tearDown(self, test):
+        cleanup.cleanUp()
+
+    def getTestSuite(self):
+        docfiles = self.getDocTestFiles(package=self.package)
+        suite = unittest.TestSuite()
+        for name in docfiles:
+            if os.path.isabs(name):
+                # We get absolute pathnames, but we need relative ones...
+                common_prefix = os.path.commonprefix([self.package.__file__,
+                                                      name])
+                name = name[len(common_prefix):]
+            suite.addTest(
+                doctest.DocFileSuite(
+                name,
+                package=self.package,
+                setUp=self.setUp,
+                tearDown=self.tearDown,
+                optionflags=self.optionflags,
+                **self.additional_options
+                ))
+        return suite
+
+
+class FunctionalDocTestSetup(BasicTestSetup):
+    """A functional test setup for packages.
+
+    A collection of methods to search for appropriate doctest files in
+    a given package. ``FunctionalTestSetup`` is also able to
+    'register' the tests found and to deliver them as a ready-to-use
+    ``unittest.TestSuite`` instance.
+
+    While the functionality to search for testfiles is mostly
+    inherited from the base class, the focus here is to setup the
+    tests correctly.
+    """
+    ftesting_zcml = os.path.join(os.path.dirname(__file__),
+                                 'ftesting.zcml')
+    layer = ZCMLLayer(ftesting_zcml, __name__,
+                      'FunctionalLayer')
+
+    globs=dict(http=HTTPCaller(),
+               getRootFolder=getRootFolder,
+               sync=sync
+               )
+
+    optionflags = (doctest.ELLIPSIS+
+                   doctest.NORMALIZE_WHITESPACE+
+                   doctest.REPORT_NDIFF)
+
+    regexp_list = [
+        '^\s*:(T|t)est-(L|l)ayer:\s*(functional)\s*',
+        ]
+
+    def setUp(self, test):
+        FunctionalTestSetup().setUp()
+
+    def tearDown(self, test):
+        FunctionalTestSetup().tearDown()
+
+    def suiteFromFile(self, name):
+        suite = unittest.TestSuite()
+        if os.path.isabs(name):
+            # We get absolute pathnames, but we need relative ones...
+            common_prefix = os.path.commonprefix([self.package.__file__, name])
+            name = name[len(common_prefix):]
+        test = FunctionalDocFileSuite(
+            name, package=self.package,
+            setUp=self.setUp, tearDown=self.tearDown,
+            globs=self.globs,
+            optionflags=self.optionflags,
+            **self.additional_options
+            )
+        test.layer = self.layer
+        suite.addTest(test)
+        return suite
+
+    def getTestSuite(self):
+        docfiles = self.getDocTestFiles(package=self.package)
+        suite = unittest.TestSuite()
+        for name in docfiles:
+            suite.addTest(self.suiteFromFile(name))
+        return suite
+
+
+def register_doctests(pkg_or_dotted_name):
+    """Return a function that requires no argument and delivers a test
+    suite.
+
+    The resulting functions are suitable for use with unittest
+    testrunners, that look for an attribute `test_suite` on module
+    level. Such::
+
+       test_suite = register_doctests(pkg)
+
+    in a module should register all tests for the package `pkg`.
+    """
+    pkg = get_package(pkg_or_dotted_name)
+    def tmpfunc():
+        suite = unittest.TestSuite()
+        suite.addTest(
+            UnitDocTestSetup(pkg).getTestSuite())
+        suite.addTest(
+            FunctionalDocTestSetup(pkg).getTestSuite())
+        return suite
+    return tmpfunc
+    

Deleted: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testing.py
===================================================================
--- Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testing.py	2008-02-02 15:45:54 UTC (rev 83426)
+++ Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testing.py	2008-02-02 15:52:49 UTC (rev 83427)
@@ -1,156 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007-2008 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test setup helpers for doctests.
-"""
-import unittest
-import os.path
-from zope.testing import doctest, cleanup
-from zope.app.testing.functional import (
-    HTTPCaller, getRootFolder, sync, ZCMLLayer, FunctionalDocFileSuite,
-    FunctionalTestSetup)
-from z3c.testsetup.base import BasicTestSetup
-from z3c.testsetup.util import get_package
-
-class UnitDocTestSetup(BasicTestSetup):
-    """A unit test setup for packages.
-
-    A collection of methods to search for appropriate doctest files in
-    a given package. ``UnitTestSetup`` is also able to 'register' the
-    tests found and to deliver them as a ready-to-use
-    ``unittest.TestSuite`` instance.
-
-    While the functionality to search for testfiles is mostly
-    inherited from the base class, the focus here is to setup the
-    tests correctly.
-
-    See file `unittestsetup.py` in the tests/testsetup directory to
-    learn more about ``UnitTestSetup``.
-    """
-
-    optionflags = (doctest.ELLIPSIS+
-                   doctest.NORMALIZE_WHITESPACE+
-                   doctest.REPORT_NDIFF)
-
-    regexp_list = [
-        '^\s*:(T|t)est-(L|l)ayer:\s*(unit)\s*',
-        ]
-
-
-    def tearDown(self, test):
-        cleanup.cleanUp()
-
-    def getTestSuite(self):
-        docfiles = self.getDocTestFiles(package=self.package)
-        suite = unittest.TestSuite()
-        for name in docfiles:
-            if os.path.isabs(name):
-                # We get absolute pathnames, but we need relative ones...
-                common_prefix = os.path.commonprefix([self.package.__file__,
-                                                      name])
-                name = name[len(common_prefix):]
-            suite.addTest(
-                doctest.DocFileSuite(
-                name,
-                package=self.package,
-                setUp=self.setUp,
-                tearDown=self.tearDown,
-                optionflags=self.optionflags,
-                **self.additional_options
-                ))
-        return suite
-
-
-class FunctionalDocTestSetup(BasicTestSetup):
-    """A functional test setup for packages.
-
-    A collection of methods to search for appropriate doctest files in
-    a given package. ``FunctionalTestSetup`` is also able to
-    'register' the tests found and to deliver them as a ready-to-use
-    ``unittest.TestSuite`` instance.
-
-    While the functionality to search for testfiles is mostly
-    inherited from the base class, the focus here is to setup the
-    tests correctly.
-    """
-    ftesting_zcml = os.path.join(os.path.dirname(__file__),
-                                 'ftesting.zcml')
-    layer = ZCMLLayer(ftesting_zcml, __name__,
-                      'FunctionalLayer')
-
-    globs=dict(http=HTTPCaller(),
-               getRootFolder=getRootFolder,
-               sync=sync
-               )
-
-    optionflags = (doctest.ELLIPSIS+
-                   doctest.NORMALIZE_WHITESPACE+
-                   doctest.REPORT_NDIFF)
-
-    regexp_list = [
-        '^\s*:(T|t)est-(L|l)ayer:\s*(functional)\s*',
-        ]
-
-    def setUp(self, test):
-        FunctionalTestSetup().setUp()
-
-    def tearDown(self, test):
-        FunctionalTestSetup().tearDown()
-
-    def suiteFromFile(self, name):
-        suite = unittest.TestSuite()
-        if os.path.isabs(name):
-            # We get absolute pathnames, but we need relative ones...
-            common_prefix = os.path.commonprefix([self.package.__file__, name])
-            name = name[len(common_prefix):]
-        test = FunctionalDocFileSuite(
-            name, package=self.package,
-            setUp=self.setUp, tearDown=self.tearDown,
-            globs=self.globs,
-            optionflags=self.optionflags,
-            **self.additional_options
-            )
-        test.layer = self.layer
-        suite.addTest(test)
-        return suite
-
-    def getTestSuite(self):
-        docfiles = self.getDocTestFiles(package=self.package)
-        suite = unittest.TestSuite()
-        for name in docfiles:
-            suite.addTest(self.suiteFromFile(name))
-        return suite
-
-
-def register_doctests(pkg_or_dotted_name):
-    """Return a function that requires no argument and delivers a test
-    suite.
-
-    The resulting functions are suitable for use with unittest
-    testrunners, that look for an attribute `test_suite` on module
-    level. Such::
-
-       test_suite = register_doctests(pkg)
-
-    in a module should register all tests for the package `pkg`.
-    """
-    pkg = get_package(pkg_or_dotted_name)
-    def tmpfunc():
-        suite = unittest.TestSuite()
-        suite.addTest(
-            UnitDocTestSetup(pkg).getTestSuite())
-        suite.addTest(
-            FunctionalDocTestSetup(pkg).getTestSuite())
-        return suite
-    return tmpfunc
-    



More information about the Checkins mailing list