Skip to content

Commit

Permalink
Update test setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
thefunny42 committed Jan 12, 2016
1 parent 3f82c8d commit 053b270
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
12 changes: 7 additions & 5 deletions src/grokcore/formlib/ftests/test_functional.py
@@ -1,10 +1,11 @@
import doctest
import re
import unittest
import grokcore.formlib

from pkg_resources import resource_listdir
from zope.testing import doctest, renormalizing

from zope.testing import renormalizing
from zope.app.wsgi.testlayer import BrowserLayer
import grokcore.formlib

FunctionalLayer = BrowserLayer(grokcore.formlib)

Expand All @@ -28,15 +29,16 @@ def suiteFromPackage(name):
dottedname,
checker=checker,
extraglobs=dict(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 ['form']:
Expand Down
26 changes: 16 additions & 10 deletions src/grokcore/formlib/tests/test_all.py
@@ -1,22 +1,27 @@
import doctest
import re
import unittest
from pkg_resources import resource_listdir
from zope.testing import doctest, cleanup, renormalizing

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


def suiteFromPackage(name):
files = resource_listdir(__name__, name)
Expand All @@ -30,16 +35,17 @@ def suiteFromPackage(name):
continue

dottedname = 'grokcore.formlib.tests.%s.%s' % (name, filename[:-3])
test = doctest.DocTestSuite(dottedname,
setUp=setUpZope,
tearDown=cleanUpZope,
checker=checker,
optionflags=doctest.ELLIPSIS+
doctest.NORMALIZE_WHITESPACE)
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 ['form']:
Expand Down

0 comments on commit 053b270

Please sign in to comment.