Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can py.test support multiple -k options?

Tags:

pytest

Can py.test supports multiple -k options? Each testcase belongs to a particular group such as _eventnotification or _interface, etc. Is it possible to run test cases that belong to either one or both at the same time? ie, run testcases that has _eventnotification or _interface in the name at the same time. I tried the following and only the testcases with _interface were executed. If that is not supported, is there another way to do this?

py.test -k "_eventnotification" -k "_interface"

like image 384
kenneth wong Avatar asked Nov 08 '12 18:11

kenneth wong


1 Answers

The bad news: pytest-2.3.3 does not support it.

The good news: i took your question as an opportunity to finally enhance "-k" behaviour, so that you can use "not", "or", "end" etc, see the [extended -k example][1]. It works now like "-m" except that it matches on (substrings of) test names, not markers. You can use this in-development pytest version with "pip install -i http://pypi.testrun.org -U pytest".

like image 94
hpk42 Avatar answered Oct 06 '22 02:10

hpk42