This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import re | ||
import unittest | ||
from pkg_resources import resource_listdir | ||
from zope.testing import doctest, cleanup, renormalizing | ||
import zope.component.eventtesting | ||
|
||
def setUpZope(test): | ||
zope.component.eventtesting.setUp(test) | ||
|
||
def cleanUpZope(test): | ||
cleanup.cleanUp() | ||
|
||
checker = renormalizing.RENormalizing([ | ||
# str(Exception) has changed from Python 2.4 to 2.5 (due to | ||
# Exception now being a new-style class). This changes the way | ||
# exceptions appear in traceback printouts. | ||
(re.compile(r"ConfigurationExecutionError: <class '([\w.]+)'>:"), | ||
r'ConfigurationExecutionError: \1:'), | ||
]) | ||
|
||
def suiteFromPackage(name): | ||
files = resource_listdir(__name__, name) | ||
suite = unittest.TestSuite() | ||
for filename in files: | ||
if not filename.endswith('.py'): | ||
continue | ||
if filename.endswith('_fixture.py'): | ||
continue | ||
if filename == '__init__.py': | ||
continue | ||
|
||
dottedname = 'grok.tests.%s.%s' % (name, filename[:-3]) | ||
test = doctest.DocTestSuite(dottedname, | ||
setUp=setUpZope, | ||
tearDown=cleanUpZope, | ||
checker=checker, | ||
optionflags=doctest.ELLIPSIS+ | ||
doctest.NORMALIZE_WHITESPACE) | ||
|
||
suite.addTest(test) | ||
return suite | ||
|
||
def test_suite(): | ||
suite = unittest.TestSuite() | ||
for name in ['adapter', 'error', 'event', 'security', 'catalog', | ||
'zcml', 'utility', 'xmlrpc', 'container', 'viewlet', | ||
'traversal', 'grokker', 'directive', | ||
'baseclass', 'application', | ||
'conflict']: | ||
suite.addTest(suiteFromPackage(name)) | ||
return suite | ||
|
||
if __name__ == '__main__': | ||
unittest.main(defaultTest='test_suite') |