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

Jonas H. report at bugs.python.org
Mon Nov 20 15:58:22 EST 2017


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

Thanks Antoine. I will need some guidance as to what are the correct places to make these changes. I'm not quite sure about the abstractions here (runner, loader, suite, case, etc.)

My PoC (see GitHub link in first post) uses a TestSuite subclass. (The subclass is only so that it's easier to assess the general implementation approach; I guess it should be put into the main class instead.)

Things I'm unsure of:

1) Is suite the correct place for this kind of feature?
2) Is the hardcoded fnmatch-based pattern matcher ok, or do we need a new abstraction "NameMatcher"?
3) Is the approach of dynamically wrapping 'skip()' around to-be-skipped test cases OK?
4) The try...catch statement around 'test.id()' is needed because there are some unit tests (unit tests for the unittest module itself) that check for some error cases/error handling in the unittest framework, and crash if we try to call '.id()' on them. Please remove the try...catch to see these errors if you're interested in the details. Is the check OK like that, or is this a code smell?

Thanks
Jonas

----------

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


More information about the Python-bugs-list mailing list