Ignore:
Timestamp:
8 Mar 2012, 19:00:51 (13 years ago)
Author:
uli
Message:

Rename all non-locales stuff from sirp to kofa.

File:
1 edited

Legend:

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

    r7581 r7811  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
    18 """Testing support for :mod:`waeup.sirp`.
     18"""Testing support for :mod:`waeup.kofa`.
    1919"""
    2020import grok
     
    2828import warnings
    2929import zope.component
    30 import waeup.sirp
     30import waeup.kofa
    3131from zope.app.testing.functional import (
    3232    ZCMLLayer, FunctionalTestSetup, getRootFolder, sync, FunctionalTestCase)
     
    3737
    3838ftesting_zcml = os.path.join(
    39     os.path.dirname(waeup.sirp.__file__), 'ftesting.zcml')
     39    os.path.dirname(waeup.kofa.__file__), 'ftesting.zcml')
    4040FunctionalLayer = ZCMLLayer(ftesting_zcml, __name__, 'FunctionalLayer',
    4141                            allow_teardown=True)
     
    4545    """
    4646    result = logging.root.manager.loggerDict.keys()
    47     ws_loggers = [x for x in result if 'waeup.sirp' in x]
     47    ws_loggers = [x for x in result if 'waeup.kofa' in x]
    4848    if ws_loggers:
    4949        # For debugging: show any remaining loggers from w.s. namespace
     
    9393
    9494def maybe_grok():
    95     """Try to grok the :mod:`waeup.sirp` package.
     95    """Try to grok the :mod:`waeup.kofa` package.
    9696
    9797    For many tests, even simple ones, we want the components defined
    98     somewhere in the :mod:`waeup.sirp` package being registered. While
     98    somewhere in the :mod:`waeup.kofa` package being registered. While
    9999    grokking the complete package can become expensive when done many
    100100    times, we only want to grok if it did not happen
     
    105105    registered and does nothing in that case.
    106106
    107     The grokking of :mod:`waeup.sirp` is done with warnings disabled.
     107    The grokking of :mod:`waeup.kofa` is done with warnings disabled.
    108108
    109109    Returns ``True`` if grokking was done, ``False`` else.
     
    122122
    123123      import unittest2 as unittest # Want Python 2.7 features
    124       from waeup.sirp.testing import (
     124      from waeup.kofa.testing import (
    125125        maybe_grok, setUpZope, cleanUpZope,
    126126        )
    127       from waeup.sirp.app import University
     127      from waeup.kofa.app import University
    128128
    129129      class MyTestCase(unittest.TestCase):
     
    153153    Here the component registration is done only once for the whole
    154154    :class:`unittest.TestCase` and no ZODB is needed. That means
    155     inside the tests you can expect to have all :mod:`waeup.sirp`
     155    inside the tests you can expect to have all :mod:`waeup.kofa`
    156156    components (utilities, adapter, events) registered but as objects
    157157    have here still have no place inside a ZODB things like 'browsing'
     
    163163         If you use the Zope testrunner (from :mod:`zope.testing`)
    164164         then you have to use appropriate layers like the
    165          :class:`waeup.sirp.testing.SIRPUnitTestLayer`.
     165         :class:`waeup.kofa.testing.KOFAUnitTestLayer`.
    166166
    167167    Usage with :mod:`zope.testing` testrunners
     
    172172    like the one defined in this module.
    173173
    174     .. seealso:: :class:`waeup.sirp.testing.SIRPUnitTestLayer`
     174    .. seealso:: :class:`waeup.kofa.testing.KOFAUnitTestLayer`
    175175
    176176    """
    177177    gsm =  getGlobalSiteManager()
    178178    # If there are any event handlers registered already, we assume
    179     # that waeup.sirp was grokked already. There might be a batter
     179    # that waeup.kofa was grokked already. There might be a batter
    180180    # check, though.
    181181    if len(list(gsm.registeredHandlers())) > 0:
     
    184184    addCheckerPublic()
    185185    warnings.simplefilter('ignore') # disable (erraneous) warnings
    186     grok.testing.grok('waeup.sirp')
     186    grok.testing.grok('waeup.kofa')
    187187    warnings.simplefilter('default') # reenable warnings
    188188    return True
     
    191191    """Register a datacenter config utility for non-functional tests.
    192192    """
    193     from waeup.sirp.interfaces import IDataCenterConfig
     193    from waeup.kofa.interfaces import IDataCenterConfig
    194194    conf = queryUtility(IDataCenterConfig)
    195195    if conf is not None:
     
    204204    """Unregister a datacenter config utility for non-functional tests.
    205205    """
    206     from waeup.sirp.interfaces import IDataCenterConfig
     206    from waeup.kofa.interfaces import IDataCenterConfig
    207207    conf = queryUtility(IDataCenterConfig)
    208208    if conf is None:
     
    214214    return
    215215
    216 class SIRPUnitTestLayer(object):
    217     """A layer for tests that groks `waeup.sirp`.
    218 
    219     A Zope test layer that registers all :mod:`waeup.sirp` components
     216class KOFAUnitTestLayer(object):
     217    """A layer for tests that groks `waeup.kofa`.
     218
     219    A Zope test layer that registers all :mod:`waeup.kofa` components
    220220    before attached tests are run and cleans this registrations up
    221     afterwards. Also basic (non-waeup.sirp) components like the event
     221    afterwards. Also basic (non-waeup.kofa) components like the event
    222222    dispatcher machinery are registered, set up and cleaned up.
    223223
     
    237237
    238238      import unittest
    239       from waeup.sirp.testing import SIRPUnitTestLayer
     239      from waeup.kofa.testing import KOFAUnitTestLayer
    240240
    241241      class MyTestCase(unittest.TestCase):
    242242
    243           layer = SIRPUnitTestLayer
     243          layer = KOFAUnitTestLayer
    244244
    245245          # per-test setups and real tests go here...
     
    331331def clear_logger_collector():
    332332    from zope.component import queryUtility, getGlobalSiteManager
    333     from waeup.sirp.interfaces import ILoggerCollector
     333    from waeup.kofa.interfaces import ILoggerCollector
    334334    collector = queryUtility(ILoggerCollector)
    335335    if collector is None:
     
    363363        If no special `checker` is passed, we use an extended
    364364        :class:`doctest.OutputChecker` as defined in
    365         :mod:`waeup.sirp.testing`.
     365        :mod:`waeup.kofa.testing`.
    366366
    367367        If optional `optionflags` are not given, use ``REPORT_NDIFF``,
    368368        ``ELLIPSIS``, and ``NORMALIZE_WHITESPACE``.
    369369
    370         .. seealso:: :data:`waeup.sirp.testing.optionflags`
    371 
    372         .. seealso:: :data:`waeup.sirp.testing.checker`
     370        .. seealso:: :data:`waeup.kofa.testing.optionflags`
     371
     372        .. seealso:: :data:`waeup.kofa.testing.checker`
    373373        """
    374374        if checker.check_output(want, got, optionflags):
     
    406406    instance by something like:
    407407
    408       from waeup.sirp.testing import get_doctest_suite
     408      from waeup.kofa.testing import get_doctest_suite
    409409      def test_suite():
    410410        suite = get_doctest_suite(['mypkg/foo.txt', 'mypkg/bar.txt'])
Note: See TracChangeset for help on using the changeset viewer.