python unittest学习7---第二类方法,assert相关方法

assertEqual(firstsecondmsg=None)

只有first和second相等时,才是通过,否则不通过。first和second可以是任意类型,当判断是否相等时调用特定类型的相等函数判断,所以会给出明确的错误信息。

assertNotEqual(firstsecondmsg=None)

只有first和second不相等时,才是通过,否则不通过。

assertTrue(exprmsg=None)assertFalse(exprmsg=None)

其中是判断bool(expr),并非是指expr为True或False

assertIs(firstsecondmsg=None)assertIsNot(firstsecondmsg=None)

assertIsNone(exprmsg=None)assertIsNotNone(exprmsg=None)

assertIn(firstsecondmsg=None)assertNotIn(firstsecondmsg=None)

assertIsInstance(objclsmsg=None)assertNotIsInstance(objclsmsg=None)

原文地址:https://www.cnblogs.com/dmtz/p/10974293.html