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

 

相关文章:

  • 2022-12-23
  • 2021-12-27
  • 2021-09-22
  • 2021-04-09
  • 2022-02-08
  • 2021-11-23
猜你喜欢
  • 2021-05-25
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案