Antoine Pitrou <pit...@free.fr> added the comment:

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 '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

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32071>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to