def tearDown(unhook_zca=True): """Undo the effects :func:`pyramid.testing.setUp`. Use this function in the ``tearDown`` method of a unit test that uses :func:`pyramid.testing.setUp` in its ``setUp`` method. If the ``unhook_zca`` argument is ``True`` (the default), call :func:`zope.component.getSiteManager.reset`. This undoes the action of :func:`pyramid.testing.setUp` called with the argument ``hook_zca=True``. If :mod:`zope.component` cannot be imported, ignore the argument. """ if unhook_zca: try: from zope.component import getSiteManager getSiteManager.reset() except ImportError: # pragma: no cover pass info = manager.pop() manager.clear() if info is not None: registry = info['registry'] if hasattr(registry, '__init__') and hasattr(registry, '__name__'): try: registry.__init__(registry.__name__) except TypeError: # calling __init__ is largely for the benefit of # people who want to use the global ZCA registry; # however maybe somebody's using a registry we don't # understand, let's not blow up pass _clearContext() # XXX why?
def test_it(self): import zope.component # no registrations made if not present ADAPTERS_REGISTERED = 4 from zope.configuration.xmlconfig import _clearContext from zope.configuration.xmlconfig import _getContext from zope.configuration.xmlconfig import XMLConfig import zope.location _clearContext() context = _getContext() XMLConfig('configure.zcml', zope.location) adapters = ([x for x in context.actions if x['discriminator'] is not None]) self.assertEqual(len(adapters), ADAPTERS_REGISTERED)
def test_it(self): import zope.component # no registrations made if not present ADAPTERS_REGISTERED = 4 from zope.configuration.xmlconfig import _clearContext from zope.configuration.xmlconfig import _getContext from zope.configuration.xmlconfig import XMLConfig import zope.location _clearContext() context = _getContext() XMLConfig('configure.zcml', zope.location) adapters = ([ x for x in context.actions if x['discriminator'] is not None ]) self.assertEqual(len(adapters), ADAPTERS_REGISTERED)
def tearDown(unhook_zca=True): """Undo the effects :func:`pyramid.testing.setUp`. Use this function in the ``tearDown`` method of a unit test that uses :func:`pyramid.testing.setUp` in its ``setUp`` method. If the ``unhook_zca`` argument is ``True`` (the default), call :func:`zope.component.getSiteManager.reset`. This undoes the action of :func:`pyramid.testing.setUp` called with the argument ``hook_zca=True``. If :mod:`zope.component` cannot be imported, ignore the argument. .. warning:: Although this method of tearing a test setup down will never disappear, after :app:`Pyramid` 1.0, using the ``begin`` and ``end`` methods of a ``Configurator`` are preferred to using ``pyramid.testing.setUp`` and ``pyramid.testing.tearDown``. See :ref:`unittesting_chapter` for more information. """ if unhook_zca: try: from zope.component import getSiteManager getSiteManager.reset() except ImportError: # pragma: no cover pass info = manager.pop() manager.clear() if info is not None: registry = info["registry"] if hasattr(registry, "__init__") and hasattr(registry, "__name__"): try: registry.__init__(registry.__name__) except TypeError: # calling __init__ is largely for the benefit of # people who want to use the global ZCA registry; # however maybe somebody's using a registry we don't # understand, let's not blow up pass _clearContext() # XXX why?
def tearDown(self): from zope.configuration.xmlconfig import _clearContext from zope.configuration.tests.samplepackage.foo import data _clearContext() del data[:]
def tearDown(*args): zope.component.testing.tearDown(*args) _clearContext()
def tearDown(self): zope.component.testing.tearDown(self) _clearContext()
def tearDown(self): from zope.configuration.xmlconfig import _clearContext from zope.configuration.tests.samplepackage.foo import data _clearContext() del data[:]