强制pytest始终运行特定的测试,无论“ -k”如何

时间:2019-11-28 18:19:24

标签: python pytest

我正在尝试向我的pytest套件添加一个测试,该测试将验证用于运行测试的python版本,如果版本低于3.8,则失败并停止测试。 我想让pytest始终运行此测试,而与在命令行上执行的任何“ -k”过滤无关。

作为参考,这是实际测试(对改进它的任何评论也将受到赞赏):

@pytest.mark.tryfirst
def test_python_version():
    version = sys.version_info
    if version.major < 3:
        logging.error("python2 is not supported")
        pytest.exit("Stopped testing")
    elif version.minor < 8:
        logging.warning("Use python 3.8 or higher for best results")

我该如何实现?

谢谢!

0 个答案:

没有答案