python unittest的使用

1,注意事项,py文件要以test开头,否则不会被执行

2,@classmethod        @classmethod

   def setupClass(self) def teardownClass(self) ----全局函数,只运行一次

3,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-06-09 00:24  行走的小z  阅读(185)  评论(0编辑  收藏  举报