[issue17457] Unittest discover fails with namespace packages and builtin modules
Claudiu.Popa
report at bugs.python.org
Sat Mar 23 23:16:35 CET 2013
Claudiu.Popa added the comment:
Yes, it iterates over every member of the namespace path. The new attached patch fixes this behaviour, by checking that each loader path starts with top_level_dir when set_implicit_top is False (if set_implicit_top is True, top_level_dir is irrelevant, start_dir will be the package name).
Also, with the original patch there were other issues:
1. if no tests were found for the namespace package, the same failure as before would have occurred at the lines:
+ if not tests:
+ tests = list(self._find_tests(start_dir, pattern))
2. it iterated every subfolder, by dropping the check for __init__.py. To fix this, I added a new keyword argument to _find_tests, `namespace` which defaults to False. If it is True, then we are checking a namespace package and subfolders will be checked even if they don't have a __init__.py file.
----------
Added file: http://bugs.python.org/file29556/unittest-17457.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17457>
_______________________________________
More information about the Python-bugs-list
mailing list