[pytest-dev] improve -k/-m exercise / want to help pytest?

holger krekel holger at merlinux.eu
Wed Oct 22 09:21:07 CEST 2014

Hi all,

is anyone interested in a little exercise that would improve pytest usage?
It doesn't require deep pytest knowledge.

This is about the "-k" and "-m" selection mini-language, 
namely expressions like:

    marker1 and marker2
    not marker1 and (marker2 or marker3)

and so forth.  The thing is that pytest currently uses Python's "eval" with
a custom dictionary which means that names such as "marker1"
cannot have dots or other punctuation and also other things are not
possible like running all tests that don't have "4.3" (coming from a
parametrized test) in it:

    -k 'not 4.3'

This would currently select all tests because "4.3" is true.  Various
people have run into traps like this.

So what is needed here are tests and code that, given a set of names
and an expression string, determines if the expression is true or not.
And everything except "and" and "or" are valid words. To use the latter
two words probably need to have some escaping like "\and" or so but
that's a bonus task :)

Anyone up for this little exercise?  Or other comments?

best and thanks,

More information about the pytest-dev mailing list