• pytest报错警告处理一:DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working


    在学习pytest时执行用例遇到一个警告,内容如下:

    DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working

    大致意思是:弃用警告:从collections中导入ABCs已被弃用,并在python3.8中将停止工作,可使用collections.abc代替它进行使用

    然后就各种百度了解,主要看到两种解决办法,做一下简单汇总:

    第一种: 在代码文件中用到了 collections 这个模块的报错;

    第二种:在代码文件中没有用到  collections 这个模块的报错;

    对应的解决办法:

    第一种情况的解决办法:

    # from collections import Iterable   ---这是会报警告的用法
    from collections.abc import Iterable ---这是不会报警告的用法
    print(isinstance('abc', Iterable))

    第二种情况的解决办法:

    这种比较坑,因为确实没有用到,所有就没办法修改导入内容来干掉警告,我就是这种情况。。

    但是万能的人啊!有了解决办法

    1、新建一个文件: pytest.ini

    2、文件中写入:

    [pytest]
    addopts = -p no:warnings

    然后再去玩一下警告就没有了!!!!

  • 相关阅读:
    CMake 用法导览
    Irrlicht 1.8.4 + Win7 + VC2015 + x64 +OpenGL编译
    VirtualBox 5.1.14 获取VirtualBox COM对象错误
    CGAL Manual/tutorial_hello_world.html
    CGAL 介绍
    Open CASCADE 基础类(Foundation Classes)
    OpenCASCADE 基础
    Nginx 反向代理详解
    修改docker容器中的hosts文件
    Jmeter 设置连接oracle数据库
  • 原文地址:https://www.cnblogs.com/Zhan-W/p/13037527.html
Copyright © 2020-2023  润新知