unittest所有断言

assertEqual(self,first,second [,msg]):fist==second通过

assertNotEqual(self,first,second [,msg])fist!=second通过

assertGreater(self,a,b [,msg]):a>b通过

assertGreaterEqual(self,a,b [,msg]):a>=b通过

assertLess(self,a,b [,msg]):a<b通过

assertLessEqual(self,a,b [,msg]):a<=b通过

assertTrue(self,expr [,msg]):expr is True通过

assertFalse(self,expr [,msg])expr is False通过

assertIs(self,expr1,expr2 [,msg]):expr1 is expr2  1和2是同一个对象通过

assertIsNot(self,expr1,expr2 [,msg]):expr1 is not expr2? 1和2不是同一个对象吗?

assertIsNone(self,obj [,msg]):obj is None?对象为空吗?

assertIsNotNone(self,obj [,msg]):obj is not None?对象不为空吗?

assertListEqual(self,list1,list2 [,msg]):list1 ==list2 ?列表1等于列表2吗?

assertDictEqual(self,d1,d2 [,msg]):dict1==dict2? 字典1等于字典2吗?

assertTupleEqual(self,first,second [,msg]):Tuple1==Tuple2?元组1等于元组2吗?

assertIn(self,member,container [,msg]):member in container? 值在容器里吗?

assertNotIn(self,member,container [,msg]):member not in container?值不在容器里吗?

assertIsInstance(self,obj,cls [,msg]):obj是cls的实例吗?

assertNotIsInstance(self,obj,cls [,msg]):obj不是cls的实例吗?

assertAlmostEqual(self,first,second,places [,msg],delta):first约等于second吗?适用于小数,palces: 指定精确到小数点后多少位,默认为7,如果在place位以内不同则断言失败;如果delta指定了值,则first和second之间的差值必须≤delta;

assertNotAlmostEqual(self,first,second,places [,msg],delta):first不约等于second吗?

assertRegex(self,text,unexpected_regexp [,msg]):验证正则表达式regexp搜索是否匹配文本text。

assertNotRegex(self,text,unexpected_regexp [,msg]):验证正则表达式regexp搜索是否不匹配文本text。

assertDictContainsSubset(self,expected,actual [,msg]):检查实际是否超预期;

assertItemEqual(self,expected_seq,actual_seq [,msg]):一个无序的序列特异性的比较。

assertMultiLineEqual(self,first,second [,msg]):2个多行的字符串是相等的

assertRaises(self,excClass,callableObj,args,kwargs):除非excclass类抛出异常失败

assertRaisesRegexp(self,expected_expected_exception,expected_regexp,...):认为在引发异常的情况下消息匹配一个正则表达式。

通过

posted @ 2020-11-04 20:05  Frank13054  阅读(112)  评论(0编辑  收藏  举报