[issue32071] Add py.test-like "-k" test selection to unittest

Jonas H. report at bugs.python.org
Mon Nov 20 18:23:53 EST 2017


Jonas H. <jonas at lophus.org> added the comment:

> > 3) Is the approach of dynamically wrapping 'skip()' around to-be-skipped test cases OK?

> I think this is the wrong approach.  A test that isn't selected shouldn't be skipped, it should not appear in the output at all.  Another reason for putting this in TestLoader :-)

My first implementation actually was mostly the test loader. Two things made me change my mind and try to make the changes in the suite code:

- The loader code really only deals with loading (i.e., finding + importing) tests. Yes it expects a file pattern like "test*.py" for identifying test case files. But apart from that it didn't "feel" right to put name based selection there.
- In py.test you'll get a console output like "5 tests passed, 1 test failed, 12 tests deselected". We can't get anything similar without making bigger changes to the test loader, runner, etc. code. Using skip() we at least have some info on "skipped" tests, although they're technically not skipped.

Are you still saying this should go to the test loader?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32071>
_______________________________________


More information about the Python-bugs-list mailing list