如何在python项目中使用unitest?

如何在python项目中使用unitest?,python,unit-testing,Python,Unit Testing,例如,我想测试这个项目。层次结构如下所示: ├── airflow │   ├── model.py │   ├── test │   │   ├── test_model.py 我在test_model.py中编写了一个测试用例来测试模型的功能: import unittest from model import BaseModel class TestModel(unittest.TestCase): def test1(self): print('here i

例如,我想测试这个项目。层次结构如下所示:

├── airflow
│   ├── model.py
│   ├── test
│   │   ├── test_model.py
我在test_model.py中编写了一个测试用例来测试模型的功能:

import unittest
from model import BaseModel

class TestModel(unittest.TestCase):
    def test1(self):
         print('here is the test logic')
我应该如何用命令行测试它

我尝试的是在
aiffort
这个主目录上运行
python-m unittest/test\u model.py
。 但它引发了一个错误:

ModuleNotFoundError: No module named 'test.test_model'
环境:


Python版本是
3.7

您使用的是什么版本的Python?任何低于3.3的版本都要求您在要导入模块的每个目录中都有
\uuuu init\uuuuuupy.py
文件from@IainShelvington刚刚测试了这个,python 3.8和3.7都需要
\uuuu init\uuuu.py
@IainShelvington Hi,我使用的是3.7,非常感谢,这是
\uuuu init\uuu
问题。