1、问题现象如下,执行时报错  imported module 'test_case_execution' has this __file__ attribute

platform win32 -- Python 3.6.5, pytest-4.6.3, py-1.8.0, pluggy-0.12.0 -- E:\Program Files (x86)\Python36-32\python.exe
cachedir: .pytest_cache
rootdir: F:\pythonLear\PyTest_allure_apitest-master
plugins: allure-adaptor2-1.7.11, rerunfailures-7.0
collecting ... collected 4 items / 1 errors / 3 selected

=================================== ERRORS ====================================
_ ERROR collecting TestCase/test_airticket/test_app_airticket_search/test_case_execution.py _
import file mismatch:
imported module 'test_case_execution' has this __file__ attribute:
  F:\pythonLear\PyTest_allure_apitest-master\TestCase\test_airticket\test_app_airticket_login\test_case_execution.py
which is not the same as the test file we want to collect:
  F:\pythonLear\PyTest_allure_apitest-master\TestCase\test_airticket\test_app_airticket_search\test_case_execution.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.39 seconds ===========================

Process finished with exit code 0

2、解决方法

在同名文件所在目录下添加__init__.py文件即可解决问题

相关文章:

  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-18
  • 2023-04-01
  • 2021-04-23
  • 2021-12-27
  • 2021-06-30
  • 2021-09-27
相关资源
相似解决方案