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-32python.exe cachedir: .pytest_cache rootdir: F:pythonLearPyTest_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:pythonLearPyTest_allure_apitest-masterTestCase est_airticket est_app_airticket_login est_case_execution.py which is not the same as the test file we want to collect: F:pythonLearPyTest_allure_apitest-masterTestCase est_airticket est_app_airticket_search est_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文件即可解决问题