pytest-2.3.4:稳定版,通过“-k expr”实现更灵活的选择

pytest-2.3.4 是 py.test 工具的一个小型稳定版,该工具提供超简洁的断言、可扩展的 fixture 机制和深度定制,用于 Python 测试。此版本包含以下修复和功能

  • 使“-k”选项接受与“-m”相同的表达式,以便可以写入:-k “name1 or name2” 等。如果您使用了诸如“TestClass.test_method”之类的特殊语法,这会带来轻微的用法不兼容性,您现在需要将其写为 -k “TestClass and test_method”才能匹配特定测试类中的特定方法。

  • 允许通过 item.keywords[…]=assignment 动态定义标记,与“-m”选项集成

  • yielded 测试函数现在将激活 autouse-fixtures,但不能接受 fixture 作为 funcargs——无论如何,建议使用 post-2.0 parametrize 功能而不是 yield,请参阅:https://pytest.cn/en/stable/example/how-to/parametrize.html

  • 修复 autouse-issue,即如果在 a/conftest.py 文件中定义了 autouse-fixtures 且测试在 a/tests/test_some.py 中,则不会发现 autouse-fixtures

  • 修复 issue226 - fixture teardowns 的 LIFO 顺序

  • 修复 issue224 - 超过 256 个字符参数的调用现在可以正常工作

  • 修复 issue91 - 在示例中添加/讨论包/目录级别的设置

  • 与 autouse 发现和调用相关的修复

特别感谢 Thomas Waldmann 发现并报告问题。

请参阅

获取一般信息。要安装或升级 pytest

pip install -U pytest # 或 easy_install -U pytest

此致,holger krekel