[Python-Dev] unittest test discovery and namespace packages

Robert Collins robertc at robertcollins.net
Fri Apr 17 20:47:19 CEST 2015


On 17 April 2015 at 19:40, Alex Shkop <a.v.shkop at gmail.com> wrote:
> Hello!
>
> There's an issue considering test discovery in unittest module. Basically it
> is about unittest module that doesn't find tests in namespace packages. For
> more info see issue http://bugs.python.org/issue23882.
>
> I'm willing to make a patch for this bug. But I need help to formulate how
> test discovery should work.
>
> Documentation states that all importable modules that match pattern will be
> loaded. This means that test modules inside namespace packages should be
> loaded too. But enabling this would change things drastically. For example
> now, running
>
> python -m unittest
>
> inside cpython source root does nothing. If we will enable test discovery
> inside namespace packages then this command will start running the whole
> python test suite in Lib/test/.

I don't think that 'scan the global namespace' makes a sensible
default definition.

The behaviour of discovery with namespace packages today requires some
key to select the namespace - either a locally discovered directory,
which happens to be a namespace package, or the name of the package to
process.

Since discovery is recursive, sub namespace packages should work, but
I note there are no explicit tests to this effect.

I'm sorry I didn't respond earlier on the tracker, didn't see the
issue in my inbox for some reason. Lets discuss there.

-Rob


-- 
Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Converged Cloud


More information about the Python-Dev mailing list