Commit 0f8c43cb authored by Stefan H. Holek's avatar Stefan H. Holek

Nuked the decorator and moved its functionality to the suite factory proper.

Fixes http://www.zope.org/Collectors/Zope/2178
parent 71a575ad
2.13 master x/poll y/cleanup-__del__ y/profile-fix 4.0a2 4.0a1 2.13.25 2.13.24 2.13.23 2.13.22 2.13.21 2.13.20 2.13.19 2.13.18 2.13.17 2.13.16 2.13.15 2.13.14 2.13.13 2.13.12 2.13.11 2.13.10 2.13.9 2.13.8 2.13.7 2.13.6 2.13.5 2.13.4 2.13.3 2.13.2 2.13.1 2.13.0 2.13.0c1 2.13.0b1 2.13.0a4 2.13.0a3 2.13.0a2 2.13.0a1 2.12.28 2.12.27 2.12.26 2.12.25 2.12.24 2.12.23 2.12.22 2.12.21 2.12.20 2.12.19 2.12.18 2.12.17 2.12.16 2.12.15 2.12.14 2.12.13 2.12.12 2.12.11 2.12.10 2.12.9 2.12.8 2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.12.0c1 2.12.0b4 2.12.0b3 2.12.0b2 2.12.0b1 2.12.0a4 2.12.0a3 2.12.0a2 2.12.0a1 2.12-last-fulltree-revision 2.11.8 2.11.7 2.11.6 2.11.5 2.11.4 2.11.3 2.11.2 2.11.1 2.11.0 2.11.0c1 2.11.0b1 2.11.0a1 2.10.13 2.10.12 2.10.11 2.10.10 2.10.9 2.10.8 2.10.7 2.10.6 2.10.5 2.10.4 2.10.3 2.10.2 2.10.2b1 2.10.1 2.10.0 2.10.0c1 2.9.12 2.9.10 2.9.9 2.9.8 2.9.7 2.9.6 2.9.5 philikon-aq-checkpoint before-merging-console-scripts-branch backups/2.10-with-ZODB3.8@83153 backups/z4-zmi@124419 backups/witsch-zope2.11-with-standard-docutils@83154 backups/witsch-2.10-with-standard-docutils@76342 backups/tyam-unicodeSplitterPatch@104722 backups/tseaver-zope.app_delenda_est@110398 backups/tseaver-no_globals_imports@94459 backups/tseaver-instlib_as_site_dir@110397 backups/tseaver-clarify_install_docs@110394 backups/tseaver-2.11-no-z2-interfaces@110391 backups/shh-2.11-zopelitelayer@80865 backups/rochael-TM_sortKey@113726 backups/hannosch-dtml-vs-accesscontrol@113161 backups/gotcha-processlifetime@113938 backups/gotcha-LP143531@113945 backups/davisagli-copy-export@123222 backups/andig-catalog-report@115049 backups/ajung-zpt-encoding-fixes@71736 backups/ajung-2-11-prep-branch@82440 backups/acripps-resourceViewletDirective@75991
No related merge requests found
...@@ -195,30 +195,27 @@ def http(request_string, handle_errors=True): ...@@ -195,30 +195,27 @@ def http(request_string, handle_errors=True):
return DocResponseWrapper(response, outstream, path, header_output) 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: class ZopeSuiteFactory:
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
self._args = args self._args = args
self._kw = kw self._kw = kw
self._layer = None
self.setup_globs() self.setup_globs()
self.setup_test_class() self.setup_test_class()
self.setup_optionflags() self.setup_optionflags()
def doctestsuite(self): 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): 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): def setup_globs(self):
globs = self._kw.setdefault('globs', {}) globs = self._kw.setdefault('globs', {})
...@@ -234,6 +231,10 @@ class ZopeSuiteFactory: ...@@ -234,6 +231,10 @@ class ZopeSuiteFactory:
if 'test_class' in self._kw: if 'test_class' in self._kw:
del self._kw['test_class'] 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 # If the test_class does not have a runTest method, we add
# a dummy attribute so that TestCase construction works. # a dummy attribute so that TestCase construction works.
if not hasattr(test_class, 'runTest'): if not hasattr(test_class, 'runTest'):
...@@ -309,26 +310,22 @@ class FunctionalSuiteFactory(ZopeSuiteFactory): ...@@ -309,26 +310,22 @@ class FunctionalSuiteFactory(ZopeSuiteFactory):
| doctest.NORMALIZE_WHITESPACE) | doctest.NORMALIZE_WHITESPACE)
@extractLayer
def ZopeDocTestSuite(module=None, **kw): def ZopeDocTestSuite(module=None, **kw):
module = doctest._normalize_module(module, depth=3) module = doctest._normalize_module(module)
return ZopeSuiteFactory(module, **kw).doctestsuite() return ZopeSuiteFactory(module, **kw).doctestsuite()
@extractLayer
def ZopeDocFileSuite(*paths, **kw): def ZopeDocFileSuite(*paths, **kw):
if kw.get('module_relative', True): 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() return ZopeSuiteFactory(*paths, **kw).docfilesuite()
@extractLayer
def FunctionalDocTestSuite(module=None, **kw): def FunctionalDocTestSuite(module=None, **kw):
module = doctest._normalize_module(module, depth=3) module = doctest._normalize_module(module)
return FunctionalSuiteFactory(module, **kw).doctestsuite() return FunctionalSuiteFactory(module, **kw).doctestsuite()
@extractLayer
def FunctionalDocFileSuite(*paths, **kw): def FunctionalDocFileSuite(*paths, **kw):
if kw.get('module_relative', True): 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() return FunctionalSuiteFactory(*paths, **kw).docfilesuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment