selenium+python学习6:Unittest测试框架的assert断言

  • A+
所属分类:python自动化

assertEqual(self,first,second [,msg]):fist==second?表达式为False,系统报错

assertNotEqual(self,first,second [,msg])fist!=second?表达式为False,系统报错

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,...):认为在引发异常的情况下消息匹配一个正则表达式。

weinxin
我的微信公众号
爱真理,得永生!          爱在灵灵久博客,网罗天下,福利大家!

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: