pytest -k标志和声明

时间:2017-06-07 14:13:49

标签: pytest

根据pytest文档,我应该可以使用'和'表达式如下:

pytest -k stringexpr # only run tests with names that match the
                     # "string expression", e.g. "MyClass and not method"
                     # will select TestMyClass.test_something
                     # but not TestMyClass.test_method_simple

我试过的是这个表达式:

pytest -v test_file.py -k “TestTest and not test_bad”

我得到的错误是:

ERROR: file not found: and

我尝试的其他变体以同样的失败告终:

pytest -v -k “TestTest and not test_bad”
pytest -v -k “TestTest and not test_bad” test_file.py

最后我的pytest版本是:3.0.3

1 个答案:

答案 0 :(得分:1)

您的是一些奇怪的印刷引号,而不是用于阻止终端参数拆分的" ascii引号,这意味着您的pytest实际上有四个参数:{{1 },“TestTestandnot

使用test_bad”时,您的示例可以正常使用。