pytesttest-discovery

How does pytest do test selection?


I am trying to figure out the expression syntax for py.test selection using the '-k' option.

I have seen the examples, but I am unclear of what the syntax options are when using the 'k' tag.

I am trying to scan the py.test source code, but so far no luck.

Can anyone give me pointers on what the syntax is for py.test test selection (-k)?


Solution

  • Mmm.. it's not well documented mainly because it's a bit confused and not that well defined. You can use 'and', 'or' and 'not' to match strings in a test name and/or its markers. At heart, it's an eval.

    For the moment (until the syntax is hopefully improved) my advice is to: