Running tests discover using these format works:
python -m unittest discover tests/folder1/folder2 -v
python -m unittest discover tests/folder1
The issue happens when I'm running the discover tests on the root directory of the tests scripts.
python -m unittest discover tests # raised ImportError
My project structure looks like this:
project_name/
src/
__init__.py
# modules
tests/
folder1/
__init__.py
folder2/
# test scripts
__init__.py
__init__.py
Based on what I read on some related post, the issue was with the PATH. but I already include the src path by running this command and the ImportError still occurs.
export PYTHONPATH=$PYTHONPATH:$(pwd)/src
python version: 3.5.0
prepending test_
to test folders fixed the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.