[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py Nuked the decorator and moved its functionality to the suite factory proper.

Stefan H. Holek stefan at epy.co.at
Sat Sep 2 10:38:11 EDT 2006


Log message for revision 69929:
  Nuked the decorator and moved its functionality to the suite factory proper.
  Fixes http://www.zope.org/Collectors/Zope/2178
  

Changed:
  U   Zope/branches/2.9/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py

-=-
Modified: Zope/branches/2.9/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
===================================================================
--- Zope/branches/2.9/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py	2006-09-02 13:11:25 UTC (rev 69928)
+++ Zope/branches/2.9/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py	2006-09-02 14:38:10 UTC (rev 69929)
@@ -195,30 +195,27 @@
     return DocResponseWrapper(response, outstream, path, header_output)
 
 
-def extractLayer(func):
-    def wrap(*args, **kw):
-        suite = func(*args, **kw)
-        tc = kw.get('test_class', None)
-        if tc and hasattr(tc, 'layer'):
-            suite.layer = tc.layer
-        return suite
-    return wrap
-
-
 class ZopeSuiteFactory:
 
     def __init__(self, *args, **kw):
         self._args = args
         self._kw = kw
+        self._layer = None
         self.setup_globs()
         self.setup_test_class()
         self.setup_optionflags()
 
     def doctestsuite(self):
-        return doctest.DocTestSuite(*self._args, **self._kw)
+        suite = doctest.DocTestSuite(*self._args, **self._kw)
+        if self._layer is not None:
+            suite.layer = self._layer
+        return suite
 
     def docfilesuite(self):
-        return doctest.DocFileSuite(*self._args, **self._kw)
+        suite = doctest.DocFileSuite(*self._args, **self._kw)
+        if self._layer is not None:
+            suite.layer = self._layer
+        return suite
 
     def setup_globs(self):
         globs = self._kw.setdefault('globs', {})
@@ -234,6 +231,10 @@
         if 'test_class' in self._kw:
             del self._kw['test_class']
 
+        # Fix for http://zope.org/Collectors/Zope/2178
+        if hasattr(test_class, 'layer'):
+            self._layer = test_class.layer
+
         # If the test_class does not have a runTest method, we add
         # a dummy attribute so that TestCase construction works.
         if not hasattr(test_class, 'runTest'):
@@ -309,26 +310,22 @@
                                        | doctest.NORMALIZE_WHITESPACE)
 
 
- at extractLayer
 def ZopeDocTestSuite(module=None, **kw):
-    module = doctest._normalize_module(module, depth=3)
+    module = doctest._normalize_module(module)
     return ZopeSuiteFactory(module, **kw).doctestsuite()
 
- at extractLayer
 def ZopeDocFileSuite(*paths, **kw):
     if kw.get('module_relative', True):
-        kw['package'] = doctest._normalize_module(kw.get('package'), depth=3)
+        kw['package'] = doctest._normalize_module(kw.get('package'))
     return ZopeSuiteFactory(*paths, **kw).docfilesuite()
 
- at extractLayer
 def FunctionalDocTestSuite(module=None, **kw):
-    module = doctest._normalize_module(module, depth=3)
+    module = doctest._normalize_module(module)
     return FunctionalSuiteFactory(module, **kw).doctestsuite()
 
- at extractLayer
 def FunctionalDocFileSuite(*paths, **kw):
     if kw.get('module_relative', True):
-        kw['package'] = doctest._normalize_module(kw.get('package'), depth=3)
+        kw['package'] = doctest._normalize_module(kw.get('package'))
     return FunctionalSuiteFactory(*paths, **kw).docfilesuite()
 
 



More information about the Zope-Checkins mailing list