Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
0f8c43cb
Commit
0f8c43cb
authored
Sep 02, 2006
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nuked the decorator and moved its functionality to the suite factory proper.
Fixes
http://www.zope.org/Collectors/Zope/2178
parent
71a575ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
20 deletions
+17
-20
lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
+17
-20
No files found.
lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
View file @
0f8c43cb
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment