我有一些有趣的菜鸟问题。
我尝试从命令行运行单元测试:
H:\PRO\pyEstimator>python src\test\python\test_power_estimator.py
Traceback (most recent call last):
File "src\test\python\test_power_estimator.py", line 2, in <module>
import src.main.python.power_estimator as power
ImportError: No module named src.main.python.power_estimator
当我尝试在所需文件夹中运行它时也会发生这种情况:
H:\PRO\pyEstimator\src\test\python>python test_power_estimator.py
我的文件夹结构如下所示。
├───src
│ │ __init__.py
│ │ __init__.pyc
│ │
│ ├───main
│ │ │ __init__.py
│ │ │ __init__.pyc
│ │ │
│ │ └───python
│ │ │ __init__.py
│ │ │ power_estimator.py
│ │ │ __init__.pyc
│ │ │ power_estimator.pyc
│ │ │
│ │ └───GUI
│ │ __init__.py
│ │
│ └───test
│ │ __init__.py
│ │
│ └───python
│ test_power_estimator.py
│ __init__.py
│ covrunner.bat
│ .coverage
│
└───doc
也许我没有看到明显的东西。我也尝试进行报道。这种方法好吗(文件结构)?