unittest常用的断言

 

断言语法 解释
assertEqual(a, b)  判断a==b
assertNotEqual(a, b) 判断a!=b
assertTrue(x) bool(x) is True
assertFalse(x) bool(x) is False
assertIs(a, b) a is b
assertIsNot(a, b)  a is not b
assertIsNone(x)  x is None
assertIsNotNone(x) x is not None
assertIn(a, b)  a in b
assertNotIn(a, b) a not in b
assertIsInstance(a, b) isinstance(a, b) 
assertNotIsInstance(a, b)  not isinstance(a, b)
posted @ 2019-01-12 10:26  李小样  阅读(130)  评论(0编辑  收藏  举报