【发布时间】:2017-10-01 15:50:07
【问题描述】:
用户可以运行如下测试用例
python /test/submit.py --pytest-args "test/cases/"
这将作为
运行pytest.main("test/cases/")`
submit.pyargparse 解析参数需要('--pytest-args', default='', type=str)
submit.py 是某个模块,其中一个 def [like initiate_test()] 将按空格分割 --pytest-args,并基于相同的分割运行 pytest -- pytest-args.
现在我想以忽略 test_name 的方式传递 --pytest-args。
但是-ignore 或-k 并没有达到我的预期。
以下是我尝试-ignore 或-k 的方法。
-ignore 似乎仅限于目录和模块。
python /test/submit.py --pytest-args "test/cases/ --ignore=test/cases/test.py::test_class::test_name"
虽然-k=test_name 执行选择性运行,但-k!=test_name 没有执行取消选择。
`python /test/submit.py --pytest-args "test/cases/ -k!=test_name"`
我也尝试了像a='-k not (test_name)'这样的shell参数
python /test/submit.py --pytest-args "test/cases/ $a"
这不起作用,因为 $a 中有空间。
注意:我无权访问 test.py 或 submit.py,所以我不能使用标记。所以解决方案应该是关于 CLI 的。
【问题讨论】:
标签: python command-line pytest