noplay
noplay

Reputation: 2421

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)?

Upvotes: 1

Views: 291

Answers (1)

pfctdayelise
pfctdayelise

Reputation: 5285

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:

  • Use --collectonly to confirm that your -k selects what you want before executing tests
  • Add markers to tests as needed to further distinguish them.

Upvotes: 0

Related Questions