我想用 py.test 排除一个测试列表(大约 5 个项目)。
我想通过命令行将此列表提供给 py.test。
我想避免修改源代码。
怎么做?
最佳答案
你可以使用 tests selecting expression , 选项是 -k
。如果您有以下测试:
def test_spam():
pass
def test_ham():
pass
def test_eggs():
pass
调用 pytest:
pytest -v -k 'not spam and not ham' tests.py
你会得到:
collected 3 items
pytest_skip_tests.py::test_eggs PASSED [100%]
=================== 2 tests deselected ===================
========= 1 passed, 2 deselected in 0.01 seconds =========
关于python - 使用 py.test 但在命令行上排除测试列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47691512/