相关疑难解决方法(0)

pytest 可以忽略特定警告吗?

我希望 pytest 忽略 RemovedInDjango20Warning。

我目前在 pytest.ini 中有这个

[pytest]
filterwarnings =
    ignore:RemovedInDjango20Warning
Run Code Online (Sandbox Code Playgroud)

这允许 pytest 运行,但不会抑制警告。

如果我添加第二个冒号,我会收到很多“内部错误”消息。

如果我添加第三个冒号,测试会运行,但不会抑制警告。

我害怕添加第四个冒号:)

~

我还尝试更具体地了解错误:

ignore:django.RemovedInDjango20Warning
Run Code Online (Sandbox Code Playgroud)

ignore:django.utils.deprecation.RemovedInDjango20Warning
Run Code Online (Sandbox Code Playgroud)

当那些运行时,我仍然每次都收到警告。

我得到的内部错误是:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/chris/.pyenv/versions/3.6.10/lib/python3.6/warnings.py", line 246, in _getcategory
INTERNALERROR>     cat = getattr(m, klass)
INTERNALERROR> AttributeError: module 'django' has no attribute 'RemovedInDjango20Warning'
INTERNALERROR> 
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/chris/.virtualenvs/website-36/lib/python3.6/site-packages/_pytest/main.py", line 196, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) …
Run Code Online (Sandbox Code Playgroud)

python pytest

14
推荐指数
1
解决办法
1662
查看次数

标签 统计

pytest ×1

python ×1