This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients ezio.melotti, jonash, michael.foord, pitrou, rbcollins
Date 2017-11-20.22:30:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
First, I should clarify that I'm not a unittest maintainer.  However, as far as I can tell, the maintainers have not been very active lately.  Also, this is a reasonably simple enhancement (at least conceptually), so I think can do without a maintainer's formal approval.

To your questions:

> 1) Is suite the correct place for this kind of feature?

At its core, TestSuite is really a glorified collection of tests.  The selection logic is inside the TestLoader, and indeed the TestLoader docstring says:

"""This class is responsible for loading tests according to various criteria and returning them wrapped in a TestSuite"""

So I would recommend putting this in TestLoader.

> 2) Is the hardcoded fnmatch-based pattern matcher ok, or do we need a new abstraction "NameMatcher"?

I think the hardcoded approach is ok.  Though to benefit readability you may want to use a predicate function instead.

> 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 :-)

> 4) The try...catch statement around '' 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

I'd ask the question differently: do you need to call .id() to do the matching at all?  Intuitively, the TestLoader probably knows about the test names already, even before it instantiates TestCases for them.  TestCases shouldn't be instantiated for tests that are not selected.
Date User Action Args
2017-11-20 22:30:08pitrousetrecipients: + pitrou, rbcollins, ezio.melotti, michael.foord, jonash
2017-11-20 22:30:07pitrousetmessageid: <>
2017-11-20 22:30:07pitroulinkissue32071 messages
2017-11-20 22:30:07pitroucreate