【问题标题】:pytest assertion message not displayed in helper function within same test module in pycharmpytest 断言消息未显示在 pycharm 中同一测试模块内的辅助函数中
【发布时间】:2022-11-09 22:26:00
【问题描述】:

我看到,如果断言发生在与我在 PyCharm 中的测试相同的模块内的辅助方法中,则似乎不会显示断言消息。

这似乎只发生在 PyCharm 中 - 从命令行运行时不会发生。

这有效:

def test_assertion_message_working():
  assert 1 == 2, "my message"
Expected :2
Actual :1
...
def test_assertion_message_working():
> assert 1 ==2, "my message"

但这没有(测试失败,但我没有收到失败消息):

def test_assertion_message_not_working():
  do_assertion()

def do_assertion():
  assert 1 == 2, "my message"
1 != 2

Expected :2 
Actual :1
...
def test_assertion_not_working():
>  do_assertion()

想知道是否需要申请任何设置(或解决方法)才能使其正常工作?

【问题讨论】:

    标签: pycharm pytest


    【解决方案1】:

    我测试了你的代码PyCharm Build #PC-222.4345.23,于 2022 年 10 月 10 日构建它在控制台中显示失败消息:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      • 2018-12-30
      • 1970-01-01
      • 2018-01-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多