unittest assert斷言


unittest常用的斷言方法

1.assertEqual(self, first, second, msg=None)

--判斷兩個參數相等:first == second

2.assertNotEqual(self, first, second, msg=None)

--判斷兩個參數不相等:first != second

3.assertIn(self, member, container, msg=None)

--判斷是字符串是否包含:member in container

4.assertNotIn(self, member, container, msg=None)

--判斷是字符串是否不包含:member not in container

5.assertTrue(self, expr, msg=None)

--判斷是否為真:expr is True

6.assertFalse(self, expr, msg=None)

--判斷是否為假:expr is False

7.assertIsNone(self, obj, msg=None)

--判斷是否為None:obj is None

8.assertIsNotNone(self, obj, msg=None)
--判斷是否不為None:obj is not None


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM