[英]Matching a parameterized test with pytest
I'm use pytest with some parameterized tests. 我在pytest中使用了一些参数化测试。 However, in more recent versions of pytest with keywords matching becoming more complex I can't figure out how to match a specific paramterization of the test. 但是,在更新版本的pytest中,关键字匹配变得越来越复杂,我无法弄清楚如何匹配测试的特定参数。
If I run my tests they look like 如果我运行我的测试他们看起来像
test_abc[backend_generator0-1]
test_abc[backend_generator0-2]
etc. But I can't figure out how to run a specific test parameterization. 但我无法弄清楚如何运行特定的测试参数化。
pytest -k "test_abc[backend_generator0-2]"
gives Syntax Error 给出语法错误
test_simple_delay[backend_generator1not 2] test_simple_delay [backend_generator1not 2]
I've tried various attempts at escaping the -
to match only the specific test but without success. 我尝试过各种尝试逃避-
只匹配特定的测试,但没有成功。
This python 2.7 on pytest 2.3.5 这个python 2.7 on pytest 2.3.5
You don't need -k
or escapes for this. 你不需要-k
或转义。 Use the node ID directly: 直接使用节点ID:
py.test 'test_abc[backend_generator0-1]'
我猜你可以做py.test -k "test_abc and generator0"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.