How to change the message in a Python AssertionError?

前端 未结 5 473
暖寄归人
暖寄归人 2020-12-07 23:57

I\'m writing per the following, in which I try to produce a decent error message when comparing two multiline blocks of Unicode text. The interior method that does the compa

5条回答
  •  情话喂你
    2020-12-08 00:42

    You can pass the desired message when creating the exception.

    raise AssertionError(line1 + ' != ' + line2)
    

    Hope this helps.

提交回复
热议问题