Pytest Helper命名空间插件
项目描述
Pytest Helper命名空间
此插件不提供任何帮助程序给pytest,但它确实在pytest中提供了一个帮助程序命名空间,允许您在conftest.py中注册帮助函数,以便在测试中使用,而无需导入。
功能
提供了一个可用的pytest命名空间,可用于注册帮助函数,而无需在您的实际测试中导入它们。
要求
无!
安装
您可以通过从PyPI使用pip安装“pytest-helpers-namespace”
$ pip install pytest-helpers-namespace
使用方法
考虑以下conftest.py文件
import pytest
@pytest.helpers.register
def foo(bar):
"""
this dumb helper function will just return what you pass to it
"""
return bar
现在考虑以下测试用例
def test_helper_namespace():
assert pytest.helpers.foo(True) is True
很简单,对吧?
您甚至可以嵌套命名空间。考虑以下conftest.py文件
pytest_plugins = ["helpers_namespace"]
import pytest
@pytest.helpers.can.haz.register
def foo(bar):
"""
this dumb helper function will just return what you pass to it
"""
return bar
现在考虑以下测试用例
def test_helper_namespace():
assert pytest.helpers.can.haz.foo(True) is True
您甚至可以向注册函数传递一个名称,这将成为辅助函数的名称。
此Pytest 插件是与Cookiecutter以及@hackebrot的Cookiecutter-pytest-plugin模板一起生成的。
文档
完整文档可以在此处查看。
项目详情
关闭
pytest-helpers-namespace-2021.12.29.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 792038247e0021beb966a7ea6e3a70ff5fcfba77eb72c6ec8fd6287af871c35b |
|
MD5 | 8c12522bb08cdb9151f6e39d309d9483 |
|
BLAKE2b-256 | e8617f1a476b375c1238d152c164f7ffb694c662da8247816947be84b5fe2e8a |
关闭
pytest_helpers_namespace-2021.12.29-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d5c0262642998437a73d85cb6ae0db57d574facc551c4a4695e92ec50469eb98 |
|
MD5 | 669b3ffba64d82e986b86e1550a6ebf0 |
|
BLAKE2b-256 | 63a734844a563c425962658f093b359636deefd19eab6783896e0d378dae88a1 |