Python 尝试运行测试时没有模块错误

Python 尝试运行测试时没有模块错误,python,python-3.x,Python,Python 3.x,我正试图以我的项目结构为基础。根据回答者的说法,我所需要做的就是这样构造我的应用程序: project-name project_name __init__.py some_module.py some_other_module.py tests __init__.py test_some_module.py test_some_other_module.py 但是,运行python

我正试图以我的项目结构为基础。根据回答者的说法,我所需要做的就是这样构造我的应用程序:

project-name
    project_name
        __init__.py
        some_module.py
        some_other_module.py
    tests
        __init__.py
        test_some_module.py
        test_some_other_module.py
但是,运行
python3.5-m unittest discover会导致以下错误:
导入错误:没有名为project\u name的模块

我的
\uuuu init\uuuu.py
文件是空的,因为我知道这会让python认为一切都是一个包。我知道有一种使用PYTHONPATH的方法,但是我也知道如果您遵循这个包系统,就没有必要使用PYTHONPATH


我做错了什么?是否有一个简单的解决方案,或者我是否需要使用不同的结构或系统来运行测试?

根据python文档中的以下链接:

我相信您需要在第一个项目名root dir中创建一个_init__u;.py文件

project-name
__init__.py
project_name
    __init__.py
    some_module.py
    some_other_module.py
tests
    __init__.py
    test_some_module.py
    test_some_other_module.py

你在哪里运行unittest命令?这就是问题所在,我从错误的目录运行unittest。你最终从哪里运行单元测试?项目名称目录。我以前是从测试目录运行的。啊,好的!我理解。谢谢你的信息。