This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: `ImportError` is` raised` only when `python -m unittest discover` is given
Type: behavior Stage: resolved
Components: Library (Lib), macOS, Tests, Windows Versions: Python 3.6, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Hiroki “h2” Horiuchi, ned.deily, paul.moore, ronaldoussoren, serhiy.storchaka, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2017-10-22 06:06 by Hiroki “h2” Horiuchi, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py Hiroki “h2” Horiuchi, 2017-10-22 06:06 runs or raises
Messages (2)
msg304729 - (view) Author: Hiroki “h2” Horiuchi (Hiroki “h2” Horiuchi) * Date: 2017-10-22 06:06
Create a package `pkg`. Put `test.py` there. Write `none = None` in `pkg/__init__.py`.
In the directory containing `pkg/`, `python [23] -m unittest pkg.test` will terminate normally, but `python [23] -m unittest discover pkg` will raise `ImportError`. The phenomenon is the same in macOS Sierra, Debian 9.0, Windows 7. I do not think this is a very kind behavior.
Thank you.
msg304731 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-22 06:30
Run

    python -m unittest discover --start-directory pkg --top-level-directory .

By default the top level directory is the same as the start directory (i.e. pkg).
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 76021
2017-10-22 06:30:25serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg304731

resolution: not a bug
stage: resolved
2017-10-22 06:06:57Hiroki “h2” Horiuchicreate