【发布时间】:2013-02-19 12:01:34
【问题描述】:
我的 Python 单元测试代码如下所示
self.assertRaises(exc.UserError, module.function, args)
这基本上断言引发了 UserError。但是,我找不到如何检查异常中的消息是否与我的正则表达式匹配。
我该怎么做? (我宁愿不编写任何额外的代码,只利用 python unittest 模块功能)
【问题讨论】:
-
这有帮助吗? stackoverflow.com/questions/8215653/… 应该有 assertRaisesRegex 吗?
标签: python unit-testing python-2.7