Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
start porting
Browse files Browse the repository at this point in the history
  • Loading branch information
goschtl committed Nov 5, 2010
1 parent bd80b1a commit fa6e29e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/grokcore/xmlrpc/tests/test_grok.py
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')

0 comments on commit fa6e29e

Please sign in to comment.