Python 在测试根目录上的Unittest发现期间导入错误

Python 在测试根目录上的Unittest发现期间导入错误,python,python-3.x,unit-testing,testing,python-unittest,Python,Python 3.x,Unit Testing,Testing,Python Unittest,使用以下格式运行测试: python -m unittest discover tests/folder1/folder2 -v python -m unittest discover tests/folder1 当我在测试脚本的根目录上运行discover测试时,就会出现这个问题 python -m unittest discover tests # raised ImportError 我的项目结构如下所示: project_name/ src/ __init_

使用以下格式运行测试:

python -m unittest discover tests/folder1/folder2 -v
python -m unittest discover tests/folder1
当我在测试脚本的根目录上运行discover测试时,就会出现这个问题

python -m unittest discover tests  # raised ImportError
我的项目结构如下所示:

project_name/
    src/
        __init__.py
        # modules
    tests/
        folder1/
            __init__.py
            folder2/
                # test scripts
                __init__.py
        __init__.py
根据我在相关帖子上读到的内容,问题在于路径。但是我已经通过运行这个命令包含了src路径,并且仍然会发生ImportError

export PYTHONPATH=$PYTHONPATH:$(pwd)/src

python版本:3.5.0

为测试文件夹预先添加
test
,修复了该问题