Ignore:
Timestamp:
30 May 2011, 01:14:13 (13 years ago)
Author:
uli
Message:

Add some functional doctest helpers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/testing.py

    r6237 r6238  
    11"""Testing support for :mod:`waeup.sirp`.
    22"""
     3import grok
     4import doctest
    35import os.path
     6import re
    47import warnings
    5 import grok
    68import zope.component
    79import waeup.sirp
    8 from zope.app.testing.functional import ZCMLLayer
     10from zope.app.testing.functional import (
     11    ZCMLLayer, FunctionalTestSetup, getRootFolder, sync)
    912from zope.component import getGlobalSiteManager
    1013from zope.security.testing import addCheckerPublic
     14from zope.testing import renormalizing
    1115from zope.testing.cleanup import cleanUp
    1216
     
    174178    def tearDown(cls):
    175179        cleanUpZope(None)
     180
     181checker = renormalizing.RENormalizing([
     182    # Relevant normalizers from zope.testing.testrunner.tests:
     183    (re.compile(r'\d+[.]\d\d\d seconds'), 'N.NNN seconds'),
     184    # Our own one to work around
     185    # http://reinout.vanrees.org/weblog/2009/07/16/invisible-test-diff.html:
     186    (re.compile(r'.*1034h'), ''),
     187    (re.compile(r'httperror_seek_wrapper:'), 'HTTPError:' )
     188    ])
     189
     190def setUp(test):
     191    FunctionalTestSetup().setUp()
     192
     193def tearDown(test):
     194    FunctionalTestSetup().tearDown()
     195
     196def doctestsuite_for_module(dotted_path):
     197    """Create a doctest suite for the module at `dotted_path`.
     198    """
     199    test = doctest.DocTestSuite(
     200        dotted_path,
     201        setUp = setUp,
     202        tearDown = tearDown,
     203        checker = checker,
     204        extraglobs = dict(
     205            getRootFolder=getRootFolder,
     206            sync=sync,),
     207        optionflags = (doctest.ELLIPSIS +
     208                       doctest.NORMALIZE_WHITESPACE +
     209                       doctest.REPORT_NDIFF),
     210        )
     211    test.layer = FunctionalLayer
     212    return test
Note: See TracChangeset for help on using the changeset viewer.