本文整理汇总了Python中pyramid.configuration.Configurator.testing_add_subscriber方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.testing_add_subscriber方法的具体用法?Python Configurator.testing_add_subscriber怎么用?Python Configurator.testing_add_subscriber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.configuration.Configurator
的用法示例。
在下文中一共展示了Configurator.testing_add_subscriber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: registerEventListener
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import testing_add_subscriber [as 别名]
def registerEventListener(event_iface=None):
""" Registers an :term:`event` listener (aka :term:`subscriber`)
listening for events of the type ``event_iface``. This method
returns a list object which is appended to by the subscriber
whenever an event is captured.
When an event is dispatched that matches ``event_iface``, that
event will be appended to the list. You can then compare the
values in the list to expected event notifications. This method
is useful when testing code that wants to call
:meth:`pyramid.registry.Registry.notify`,
:func:`zope.component.event.dispatch` or
:func:`zope.component.event.objectEventNotify`.
The default value of ``event_iface`` (``None``) implies a
subscriber registered for *any* kind of event.
.. warning:: This API is deprecated as of :app:`Pyramid` 1.0.
Instead use the
:meth:`pyramid.configuration.Configurator.testing_add_subscriber`
method in your unit and integration tests.
"""
registry = get_current_registry()
config = Configurator(registry=registry)
return config.testing_add_subscriber(event_iface)