zoukankan      html  css  js  c++  java
  • 不同目录存在相同名称的py文件,执行时,报错的解决方法

    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文件即可解决问题

  • 相关阅读:
    Java中的pom.xml
    Java中request请求配置
    java,名称工具类。手机号加星。
    Java数据库查询与循环处理
    php接口分页
    java中sql映射机制
    java中的model映射
    Java启动项目
    httpSession.removeAttribute 移除header中的属性
    mybatisplus 查询数据
  • 原文地址:https://www.cnblogs.com/testlearn/p/11111123.html
Copyright © 2011-2022 走看看