断言(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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM