python unittest助手改编自
test的Python项目详细描述
来自Testify的所有断言,但通过添加py3k支持清理了一点。
应该与python 2.5-3.3和pypy 1.9一起使用。以确保它对您有效:python setup.py test。
安装
没有依赖关系。简单地说:pip install testy
示例用法
importreimportunittestfromtesty.assertionsimportassert_dict_subset,assert_raises,assert_match_regexclassMyTestCase(unittest.TestCase):defsetUp(self):self.x=dict(a=1,b=2)deftest_x(self):assert_dict_subset(dict(b=2),self.x)deftest_exception(self):withassert_raises(TypeError):raiseTypeError("Call some code you expect to fail here.")deftest_pattern(self):pattern=re.compile('\w')assert_match_regex(pattern,'abc')deftearDown(self):self.x=Noneif__name__=="__main__":unittest.main()