python - pylint 提示 py.test : "Module ' pytest' has no 'raises' member"

标签 python pylint pytest

使用以下代码:

import pytest
def test_a():
    with pytest.raises(Exception):
        1/0

如果我在上面运行 pylint,它会提示“raises”不是模块 pytest 的成员:

E:  3,9:test_a: Module 'pytest' has no 'raises' member

这显然不是真的。知道为什么 pylint 会犯这样的错误吗?这是已知错误吗?

py.test 版本:

> py.test --version
This is py.test version 2.2.3, imported from C:\Python27\lib\site-packages\pytest.pyc

PyLint 版本:

> pylint --version
No config file found, using default configuration
pylint 0.25.1,
astng 0.23.1, common 0.57.1
Python 2.7.2 (default, Jun 24 2011, 12:22:14) [MSC v.1500 64 bit (AMD64)]

最佳答案

您可以在 pylintrc 文件中将其静音: ignored-classes=pytest

关于python - pylint 提示 py.test : "Module ' pytest' has no 'raises' member",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10647165/

相关文章:

python - 远程访问ipython笔记本服务器抛出异常

python - 如何在 Jupyter 笔记本中打印时重新定位光标

python - 我已经安装了pylint。但它不会按类型、原始指标、重复等显示统计信息。表。如何让 pylint 显示它?

python - 如何告诉 pylint 组合类的子类可以访问父成员?

python - 如何在不创建 conn.cursor() 的情况下检查/打印 psycopg2 动态查询 Compose

python - 迭代 Dataframe 时的嵌套 for 循环优化

Python - 使用正则表达式过滤数据

python - Pylintrc 配置仅显示错误

pytest - 在测试执行之前无法获取 pytest 命令行参数?

django - Pytest 不能与 Django 和 Docker 一起使用 - AssertionError : local ('/dev/console' ) is not a file