zoukankan      html  css  js  c++  java
  • pytest警告DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working

    问题现象

    =========================================================================================== warnings summary =========================================================================================== 
    f:python3.7libsite-packagesurllib3utilselectors.py:14
      f:python3.7libsite-packagesurllib3utilselectors.py:14: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
        from collections import namedtuple, Mapping
    
    f:python3.7libsite-packagesurllib3\_collections.py:2
      f:python3.7libsite-packagesurllib3\_collections.py:2: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
        from collections import Mapping, MutableMapping
    

    问题分析

    大致意思是:弃用警告:从collections中导入ABCs已被弃用,并在python3.8中将停止工作,可使用collections.abc代替它进行使用
    然后就各种百度了解,主要看到两种解决办法,做一下简单汇总:
    第一种: 在代码文件中用到了 collections 这个模块的报错;
    第二种:在代码文件中没有用到 collections 这个模块的报错;

    解决方法

    1. 如果有使用这个方法
    # from collections import Iterable   ---这是会报警告的用法
    from collections.abc import Iterable ---这是不会报警告的用法
    
    1. 如果根本没用调用这个方法
      那么只能通过pytest的告警过滤了
      创建pytest.ini文件,写入下面内容并保存
    [pytest]
    addopts = -p no:warnings
    

    运行后,告警消除

  • 相关阅读:
    Flink入门(五)——DataSet Api编程指南
    不仅仅是双11大屏—Flink应用场景介绍
    Kafka2.4发布——新特性介绍(附Java Api Demo代码)
    Vmvare扩展虚拟机磁盘大小
    Ambari2.7.3.0添加组件
    Flink入门(四)——编程模型
    Flink入门(三)——环境与部署
    Flink入门(二)——Flink架构介绍
    「漏洞预警」Apache Flink 任意 Jar 包上传导致远程代码执行漏洞复现
    直击面试,聊聊 GC 机制
  • 原文地址:https://www.cnblogs.com/huny/p/14346387.html
Copyright © 2011-2022 走看看