[issue32071] Add py.test-like "-k" test selection to unittest
Jonas H.
report at bugs.python.org
Sat Nov 18 13:18:05 EST 2017
Jonas H. <jonas at lophus.org> added the comment:
Just to be clear, the current implementation is limited to substring matches. It doesn't support py.test like "and/or" combinators. (Actually, py.test uses 'eval' to support arbitrary patterns.)
So say we have test case
SomeClass
test_foo
test_bar
Then
- python -m unittest -k fo matches "test_foo"
- python -m unittest -k Some matches "test_foo" and "test_bar"
- python -m unittest -k some matches nothing
The -k option may be used multiple times, combining the patterns with "or":
- python -m unittest -k fo -k b matches "test_foo" and "test_bar"
It's also possible to use glob-style patterns, like -k "spam_*_eggs".
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32071>
_______________________________________
More information about the Python-bugs-list
mailing list