【发布时间】:2013-02-05 16:04:08
【问题描述】:
我正在尝试在我的单元测试中进行一些模式匹配。
我的源代码如下
MY_CODE = "The input %s is invalid"
def my_func():
check_something()
return MY_CODE % some_var
在我的测试中,我有类似的东西
def test_checking(self):
m = app.my_func()
# How do I assert that m is of the format MY_CODE???
# assertTrue(MY_CODE in m) wont work because the error code has been formatted
我想要断言上述内容的最佳方式?
【问题讨论】:
标签: python string unit-testing python-2.7 string-formatting