[issue23882] unittest discovery doesn't detect namespace packages when given no parameters

Inada Naoki report at bugs.python.org
Sat Jul 18 23:55:53 EDT 2020


Inada Naoki <songofacandy at gmail.com> added the comment:

Searching into directory without __init__.py recursively is not only inefficient, but also dangerous.

 project/
   - mylib/
      - __init__.py
      - foo.py
   - tests/
      - __init__.py
      - test_foo.py
   - tools/
      - bin/
          - dangerous_script.py

What happens if `python -m unittest` is run in the project root?
Who excepts tools/bin/dangarous.py is executed?

My conclution is:

* People shouldn't abuse PEP 420.  Omitting __init__.py is allowed only for namespace package.
* Namespace package should be searched based on PEP 420 rule. Don't search into regular directory unless it is specified.

----------

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


More information about the Python-bugs-list mailing list