断言错误在python中返回空字符串

tip*_*ipu 5 python assert

我正在这样做:

try: self.failUnless(sel.is_text_present("F!")) #sel.is_text_present("F!") is false
except AssertionError, e: 
    print("x"+e+"y")
    sys.exit()
Run Code Online (Sandbox Code Playgroud)

除了xy,它什么都不打印。没有类名或其他任何东西。AssertionError 中的错误通常包含什么?

编辑:显然用户提供了自己的消息。硒产生了其中的许多:

except AssertionError, e: self.verificationErrors.append(str(e))
Run Code Online (Sandbox Code Playgroud)

根本不发送消息,因此它将一堆空字符串附加到 verifyErrors 中。

Dan*_*man 4

不要从断言中发现错误。unittest 模块中的所有断言都采用最后一个参数 ,msg这是断言失败时要引发的消息。如有必要,请将调试放在那里。