_____________________________________________________________________________________ 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文件;在项目的跟目录执行,也可以,亲测可以


 
                    
            
                

相关文章:

  • 2022-01-04
  • 2021-08-29
  • 2022-01-04
  • 2021-06-06
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
猜你喜欢
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2021-09-07
  • 2021-11-09
  • 2022-01-10
  • 2021-07-03
相关资源
相似解决方案