_____________________________________________________________________________________ ERROR collecting test_panda_1.py ______________________________________________________________________________________
ImportError while importing test module 'D:\pythonhome\pandabus_API_test_pytest\case\test_panda_1.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test_panda_1.py:7: in <module>
from common.logger import log
E ModuleNotFoundError: No module named 'common'
方法 1 在要執行pytest 的根目錄新建 conftest.py文件;文件內容
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ‘..‘)))
方法2 pyteset 在執行測試test case目錄下每個目錄都包含__init__.py文件;在項目的跟目錄執行,也可以,親測可以