nameko.testing.utils¶
Common testing utilities.
Attributes¶
Classes¶
入口点封装类 |
|
Creates and destroys resources in background threads. |
Functions¶
|
Inspect |
|
Inspect |
|
Return a context manager that waits |
|
Blocks until |
|
Assert that |
|
|
|
|
|
|
|
Module Contents¶
- nameko.testing.utils.get_extension(container, extension_cls, **match_attrs)[源代码]¶
Inspect
container.extensions
and return the first item that is an instance ofextension_cls
.Optionally also require that the instance has an attribute with a particular value as given in the
match_attrs
kwargs.
- nameko.testing.utils.get_container(runner, service_cls)[源代码]¶
Inspect
runner.containers
and return the first item that is hosting an instance ofservice_cls
.
- nameko.testing.utils.wait_for_call(timeout, mock_method)[源代码]¶
Return a context manager that waits
timeout
seconds formock_method
to be called, yielding the mock if so.Raises an
eventlet.Timeout
if the method was not called withintimeout
seconds.
- nameko.testing.utils.wait_for_worker_idle(container, timeout=10)[源代码]¶
Blocks until
container
has no running workers.Raises an
eventlet.Timeout
if the method was not called withintimeout
seconds.
- nameko.testing.utils.assert_stops_raising(fn, exception_type=Exception, timeout=10, interval=0.1)[源代码]¶
Assert that
fn
returns successfully withintimeout
seconds, trying everyinterval
seconds.If
exception_type
is provided, fail unless the exception thrown is an instance ofexception_type
. If not specified, any :class:`Exception instance is allowed.
- class nameko.testing.utils.DummyProvider(method_name=None)[源代码]¶
Bases:
nameko.extensions.Entrypoint
入口点封装类
- Parameters:
- expected_exceptions异常类或异常类元组
指定可能由调用者引起的异常(例如,通过提供错误的参数)。 保存在入口点实例中作为
entrypoint.expected_exceptions
,供其他扩展(例如监控系统)后续检查。- sensitive_arguments字符串或字符串元组
将参数或参数的一部分标记为敏感。保存在入口点实例中作为
entrypoint.sensitive_arguments
, 供其他扩展(例如日志系统)后续检查。- seealso: