[Python-Dev] unittest test discovery and namespace packages

2015-04-17 Thread Alex Shkop
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/.

So I'm looking for someone's help to clarify how test discovery should work.

Thanks,
Alex
--
Issue in bugtracker - http://bugs.python.org/issue23882
Documentation for discover() method -
https://docs.python.org/3.4/library/unittest.html#unittest.TestLoader.discover
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] unittest test discovery and namespace packages

2015-04-17 Thread Robert Collins
On 17 April 2015 at 19:40, Alex Shkop a.v.sh...@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 rbtcoll...@hp.com
Distinguished Technologist
HP Converged Cloud
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com