[Checkins] SVN: z3c.testsetup/branches/ulif-sepfunctesting/src/z3c/testsetup/functional/testgetter.py Remove non-ftest code.

Uli Fouquet uli at gnufix.de
Tue Jun 24 18:48:35 EDT 2008


Log message for revision 87726:
  Remove non-ftest code.

Changed:
  U   z3c.testsetup/branches/ulif-sepfunctesting/src/z3c/testsetup/functional/testgetter.py

-=-
Modified: z3c.testsetup/branches/ulif-sepfunctesting/src/z3c/testsetup/functional/testgetter.py
===================================================================
--- z3c.testsetup/branches/ulif-sepfunctesting/src/z3c/testsetup/functional/testgetter.py	2008-06-24 22:43:40 UTC (rev 87725)
+++ z3c.testsetup/branches/ulif-sepfunctesting/src/z3c/testsetup/functional/testgetter.py	2008-06-24 22:48:35 UTC (rev 87726)
@@ -11,7 +11,7 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""TestGetters and TestCollectors.
+"""TestGetters and TestCollectors that include functional tests.
 
 TestGetters wrap ordinary TestSetups and TestCollectors wrap
 TestGetters. They ease the writing of often used ``test_suite()``
@@ -20,121 +20,19 @@
 See testgetter.txt to learn more about this stuff.
 """
 import unittest
-from z3c.testsetup.doctesting import UnitDocTestSetup, FunctionalDocTestSetup
+from z3c.testsetup.doctesting import UnitDocTestSetup
+from z3c.testsetup.functional.doctesting import FunctionalDocTestSetup
+from z3c.testsetup.testgetter import (BasicTestGetter, UnitDocTestGetter,
+                                      PythonTestGetter, BasicTestCollector)
 from z3c.testsetup.testing import UnitTestSetup
 from z3c.testsetup.util import get_package, get_keyword_params
 
-class BasicTestGetter(object):
-    """Abstract base for TestGetters.
-
-    TestGetters are a replacement for the test_suite() functions often
-    defined in test setup modules. They are more elegant, more
-    flexible, reusable and better looking ;-)
-    """
-    defaults = {}
-    settings = {}
-    args = ()
-
-    def __init__(self, pkg_or_dotted_name, *args, **kw):
-        self.args = args
-        if 'defaults' in kw.keys():
-            self.defaults = kw['defaults']
-            del kw['defaults']
-        self.settings = kw
-        self.package = get_package(pkg_or_dotted_name)
-        self.initialize()
-        return
-
-    def initialize(self):
-        """Convenience method called at end of constructor.
-
-        Might be usable for derived classes.
-        """
-        pass
-
-    def __call__(self):
-        """Get a testsuite.
-        """
-        self.filterKeywords()
-        suite = unittest.TestSuite()
-        suite.addTest(
-            self.wrapped_class(
-                self.package, **self.settings).getTestSuite()
-            )
-        return suite
-    
-    def filterKeywords(self):
-        """Filter keywords passed to the constructor.
-
-        See testgetter.txt for deeper insights.
-        """
-        new_kws = self.defaults.copy()
-        new_kws.update(self.settings)
-        self.settings = new_kws
-        if not getattr(self, 'wrapped_class', None):
-            return
-        supported_kws = get_keyword_params(self.wrapped_class, '__init__')
-        for kw, val in new_kws.items():
-            if (kw.startswith(self.special_char) and
-                kw[1:] in supported_kws):
-                new_kws[kw[1:]] = val
-            if kw not in supported_kws:
-                del new_kws[kw]
-        self.settings = new_kws
-        return
-
-    def getTestSuite(self):
-        """A convenience method.
-
-        Some people might expect this method to exist.
-        """
-        return self.__call__()
-
-
 class FunctionalDocTestGetter(BasicTestGetter):
     """Collect functional doctests.
     """
-
     wrapped_class = FunctionalDocTestSetup
     special_char = 'f'
 
-class UnitDocTestGetter(BasicTestGetter):
-    """Collect unit doctests.
-    """
-
-    wrapped_class = UnitDocTestSetup
-    special_char = 'u'
-    
-class PythonTestGetter(BasicTestGetter):
-    """Collect 'normal' python tests.
-    """
-
-    wrapped_class = UnitTestSetup
-    special_char = 'p'
-
-
-class BasicTestCollector(BasicTestGetter):
-    """Abstract base of TestCollectors.
-
-    TestCollectors are TestGetters, that can handle several TestGetter
-    types at once.
-    """
-    
-    handled_getters = []
-    def __call__(self):
-        """Return a test suite.
-        """
-        suite = unittest.TestSuite()
-        for getter_cls in self.handled_getters:
-            getter = getter_cls(self.package, **self.settings)
-            # Merge our defaults with target defaults...
-            target_defaults = getattr(getter, 'defaults', {})
-            self_defaults = getattr(self, 'defaults', {})
-            getter.defaults = target_defaults.copy()
-            getter.defaults.update(self_defaults)
-            suite.addTest(getter.getTestSuite())
-        return suite
-
 class DocTestCollector(BasicTestCollector):
     """A TestCollector that wraps functional doctests and unit doctests.
     """



More information about the Checkins mailing list