jjh
jjh

Reputation: 554

Matching a parameterized test with pytest

I'm use pytest with some parameterized tests. 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.

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]

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

Upvotes: 1

Views: 1349

Answers (2)

David Tucker
David Tucker

Reputation: 56

You don't need -k or escapes for this. Use the node ID directly:

py.test 'test_abc[backend_generator0-1]'

Upvotes: 2

hpk42
hpk42

Reputation: 23561

You can just do py.test -k "test_abc and generator0" i guess.

Upvotes: 1

Related Questions