【问题标题】:How to view runtime warnings in PyCharm when running tests using pytest?使用pytest运行测试时如何在PyCharm中查看运行时警告?
【发布时间】:2023-02-11 03:08:52
【问题描述】:

在 PyCharm 2022.3.2(专业版)中使用 pytest (6.2.4) 和 Python 3.9 运行测试时,我在 PyCharm 控制台窗口中得到以下结果:

D:\cenv\python.exe "D:/Program Files (x86)/JetBrains/PyCharm 2022.3.2/plugins/python/helpers/pycharm/_jb_pytest_runner.py" --path D:\tests\test_k.py 测试于下午 6:49 开始...... 使用参数 D:\tests\test_k.py --no-header --no-summary -q 在 D:\tests 中启动 pytest

=============================测试会话开始================== =========== 收集 ... 收集了 5 件物品

test_k.py::test_init test_k.py::test_1 test_k.py::test_2 test_k.py::test_3 test_k.py::test_4

======================= 5 次通过,4.50 秒内有 278 次警告 =================== ====

进程结束,退出代码为 0 通过 [ 20%] 通过 [ 40%] 通过 [ 60%] 通过 [ 80%] 通过 [100%]

所以实际的警告不显示。仅显示警告数 (278)。

我试过:

  1. 选择:Pytest:不要在高级设置中添加“--no-header --no-summary -q”

  2. 在运行/调试配置窗口中将附加参数设置为 -Wall

  3. 在运行/调试配置窗口中将解释器选项设置为 -Wall

    和所有排列,都无济于事。有没有办法在 PyCharm 控制台窗口中使用 PyCharm 中的 pytest 运行测试时显示所有运行时警告?

【问题讨论】:

    标签: python pycharm pytest warnings


    【解决方案1】:

    我认为您也可以尝试通过更改执行测试的方式以编程方式添加 verbositycollect warnings

    【讨论】:

      猜你喜欢
      • 2019-11-04
      • 2020-04-25
      • 2021-10-20
      • 2018-08-28
      • 2021-05-05
      • 1970-01-01
      • 2013-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多