[issue23882] unittest discovery and namespaced packages

Alex Shkop report at bugs.python.org
Wed Apr 8 11:57:53 CEST 2015


Alex Shkop added the comment:

Spent some time looking into this one. Looks like the problem is in TestLoader.discover() method. There are couple of issues I found in it, all caused by same assumption.

Documentation [1] states that all test modules found by discover() method should be importable from top_level_dir. Whenever this method finds a subdirectory of start_dir it checks for __init__.py file. If there's no __init__.py then finder assumes that files within this package is not importable and stops recursion. This kind of 'importablity' check is not valid since we have namespace packages.

I'm not sure what should be done to fix this issue. We can change documentation to state that only regular packages with tests will be discovered. Or we can fix 'importability' checks, which will mean that all tests in all subdirectories will be discovered.

[1] https://docs.python.org/3.4/library/unittest.html#unittest.TestLoader.discover

----------
nosy: +ashkop

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23882>
_______________________________________


More information about the Python-bugs-list mailing list