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

  • 相关阅读:
    dhcp服务配置
    配置一台时间服务器
    创建kvm虚拟机
    实现跳板机
    双向同步使用unison
    17、 Shell脚本题:编写个shell脚本将当前目录下大于10K的文件转移到/tmp目录下。
    find 命令
    权限管理:建立一个经理组
    使用sudo命令
    [转]tftp在put上传的时候显示File not found的解决办法
  • 原文地址:https://www.cnblogs.com/testlearn/p/11111123.html
Copyright © 2011-2022 走看看