我正在使用pytest基于python virtualenv进行测试,此问题有一些先决条件。 1>使用python virtualenv进行pytest 2>安装在virtualenv上的软件包 3>我可以在“ python test_load_dashboard_page.py”下成功运行,但不能执行“ pytest test_load_dashboard_page.py”,错误详细信息如下:
ImportError while importing test module '/Users/xxx/PycharmProjects/mlearn/apiAutomation/testSuites/test_load_dashboard_page.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test_load_dashboard_page.py:2: in <module>
from apiAutomation.functionsPages import load_dashboard_page as ldp
E ModuleNotFoundError: No module named 'apiAutomation'