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

Commit

Permalink
Update test setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
thefunny42 committed Jan 13, 2016
1 parent 8564406 commit 15be927
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
14 changes: 9 additions & 5 deletions src/grokcore/xmlrpc/ftests/test_grok_functional.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import doctest
import re
import unittest, doctest
import grokcore.xmlrpc

import unittest
from pkg_resources import resource_listdir

from zope.testing import renormalizing
from zope.app.wsgi.testlayer import BrowserLayer, http
import grokcore.xmlrpc

FunctionalLayer = BrowserLayer(grokcore.xmlrpc)

Expand All @@ -13,6 +14,7 @@
(re.compile(r'httperror_seek_wrapper:', re.M), 'HTTPError:'),
])


def http_call(method, path, data=None, **kw):
"""Function to help make RESTful calls.
Expand All @@ -32,6 +34,7 @@ def http_call(method, path, data=None, **kw):
request_string += data
return http(request_string, handle_errors=False)


def suiteFromPackage(name):
files = resource_listdir(__name__, name)
suite = unittest.TestSuite()
Expand All @@ -48,14 +51,15 @@ def suiteFromPackage(name):
extraglobs=dict(http_call=http_call,
http=http,
getRootFolder=FunctionalLayer.getRootFolder),
optionflags=(doctest.ELLIPSIS+
doctest.NORMALIZE_WHITESPACE+
optionflags=(doctest.ELLIPSIS +
doctest.NORMALIZE_WHITESPACE +
doctest.REPORT_NDIFF))
test.layer = FunctionalLayer

suite.addTest(test)
return suite


def test_suite():
suite = unittest.TestSuite()
for name in ['xmlrpc']:
Expand Down
25 changes: 15 additions & 10 deletions src/grokcore/xmlrpc/tests/test_grok.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import doctest
import re
import unittest

from pkg_resources import resource_listdir
from zope.testing import doctest, cleanup, renormalizing
import zope.component.eventtesting
from zope.testing import cleanup, renormalizing


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:'),
])
(re.compile(
r"ConfigurationExecutionError: <class '([\w.]+)'>:"),
r'ConfigurationExecutionError: \1:')])


def suiteFromPackage(name):
files = resource_listdir(__name__, name)
Expand All @@ -28,20 +31,22 @@ def suiteFromPackage(name):
continue

dottedname = 'grokcore.xmlrpc.tests.%s.%s' % (name, filename[:-3])
test = doctest.DocTestSuite(dottedname,
tearDown=cleanUpZope,
checker=checker,
optionflags=doctest.ELLIPSIS+
doctest.NORMALIZE_WHITESPACE)
test = doctest.DocTestSuite(
dottedname,
tearDown=cleanUpZope,
checker=checker,
optionflags=doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE)

suite.addTest(test)
return suite


def test_suite():
suite = unittest.TestSuite()
for name in ['xmlrpc']:
suite.addTest(suiteFromPackage(name))
return suite


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')

0 comments on commit 15be927

Please sign in to comment.