有没有办法选择pytest测试从文件运行?例如,包含要执行的测试列表的文件foo.txt:
tests_directory/foo.py::test_001
tests_directory/bar.py::test_some_other_test
Run Code Online (Sandbox Code Playgroud)
或者有没有办法从pytest的不同目录中选择多个测试,测试名称中没有共同的模式?
py.test -k <pattern> 允许单一模式.
一种选择是针对每个测试使用pytest.mark,但我的要求是运行来自不同文件的不同测试组合.
有没有办法为每个模式指定多个模式和测试文件名?或者有没有办法在文件中指定确切的测试路径并将该文件作为pytest的输入提供?或者是否有可用于此目的的钩子功能?
阅读http://doc.pytest.org/en/latest/example/markers.html我看到了基于标记包含或排除某些 python 测试的示例。
包含:
pytest -v -m webtest
Run Code Online (Sandbox Code Playgroud)
不包括:
pytest -v -m "not webtest"
Run Code Online (Sandbox Code Playgroud)
如果我想为包含和排除指定多个标记怎么办?