断言(assert)

unittest常用的断言方法

1.assertEqual(self, a, b msg=None)

--判断两个参数相等:a == b

2.assertNotEqual(self, a, b, msg=None)

--判断两个参数不相等:a != b

3.assertIn(self, hello,helloword, msg=None)

--判断是字符串是否包含:hello in helloword
4.asserNotIn(self,s,hello,msg=None)
--判断是字符串是否不包含:s not in hello 5.assertTrue(self, a, msg=None) --判断是否为真:a is True 6.assertFalse(self, b, msg=None) --判断是否为假:b is False 7.assertIsNone(self, c, msg=None) --判断是否为None:c is None 8.assertIsNotNone(self, d, msg=None) --判断是否不为None:d is not None

 

posted @ 2019-06-04 13:42  zhaoxixi  阅读(2214)  评论(0编辑  收藏  举报