pytest帮助程序命名空间

pytest-helpers-namespace的Python项目详细描述


See Build Status on Travis CISee Build Status on AppVeyorCode CoveragePyPI Package latest releasePyPI Package monthly downloadsPyPI WheelSupported versionsSupported implementations

此插件不向pytest提供任何帮助程序,但是, 在pytest中提供一个helpers命名空间,使您能够注册helper 在测试中使用的conftest.py中的函数 以导入它们。

功能

  • 提供可用于注册的helperspytest命名空间 helper函数,而不需要在实际测试中将它们导入到 使用它们。

要求

  • 没有!

安装

您可以通过pipPyPI

$ pip install pytest-helpers-namespace

用法

考虑以下conftest.py文件:

pytest_plugins=['helpers_namespace']importpytest@pytest.helpers.registerdeffoo(bar):'''
    this dumb helper function will just return what you pass to it
    '''returnbar

现在考虑下面的测试用例:

deftest_helper_namespace():assertpytest.helpers.foo(True)isTrue

很简单吧?!

甚至可以嵌套名称空间。考虑以下conftest.py文件:

pytest_plugins=['helpers_namespace']importpytest@pytest.helpers.can.haz.registerdeffoo(bar):'''
    this dumb helper function will just return what you pass to it
    '''returnbar

现在考虑下面的测试用例:

deftest_helper_namespace():assertpytest.helpers.can.haz.foo(True)isTrue

您甚至可以向register函数传递一个名称,这将是helper函数的名称。

贡献

我们非常欢迎您的贡献。测试可以用tox运行,请确保 在提交请求之前,覆盖范围至少保持不变。

许可证

根据Apache Software License 2.0许可证的条款分发, “pytest helpers namespace”是免费的开源软件。

问题

如果您遇到任何问题,请file an issue连同详细的 描述。

更改日志

V2019.1.8

  • 在处理任何conftest.py文件之前修补pytest。

V2019.1.7

  • 支持pytest>;=4.1

V2019.1.6.后1

  • 除了锁定到pytest<;4.0之外,没有做任何更改

V2019.1.6

  • 除了锁定到pytest<;4.1之外,没有做任何更改

2017.11.11版

  • 允许将字符串传递给register函数,该函数将成为助手名称

2016.7.10版

  • 允许已注册的函数继续作为常规函数运行。#4

2016.4.15版

  • 隐藏pytest失败中的FuncWrapper回溯。#3。感谢Logan GlickField(@lsglick

2016.4.5版

  • 使用包装类而不是向函数添加属性。

2016.4.3版
  • 当helper函数或命名空间被 已重写。#1

2016.3.2版
  • 首次工作释放

这个Pytest插件是用Cookiecutter@hackebrotCookiecutter-pytest-plugin模板。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Redis MQ在springboot程序中与JDBC存在问题   java比较数组中的索引值并返回新数组   java为什么Jericho解析器不能解析这个HTML代码?   使用java的文件IO   使用OpenCV实现java RGB到LMS颜色空间的转换   java有什么区别吗?SwingWorker#发布vs SwingUtilities#调用器   java在列(数量)中,我也有一些double和N/a类型的值。如何使用比较器对两者进行排序?   java HSQLDB:。脚本文件在并行执行多个项目[多线程环境]期间自动删除?   java如何在JAXWS出现异常时发送自定义响应消息而不是错误消息?   SpringJavaTomcat:重新加载上下文。不重新启动服务器的xml   JAVA中的对象数组提供InputMismatchException   java是分析和过滤独特句子的最佳算法?   eclipse编写自定义重构脚本的最佳java库是什么?   来自ArrayList的java随机背景<Drawable>   java提取服务器证书   java异常:尝试调用虚拟方法“int com”。谷歌。安卓gms。地方位置请求。空对象引用上的b()