标签:letter rtt let mon als == imp sel test
import unittest
class xixi(unittest.TestCase):
def test_1(self):
a=3
b=4
#self.assertEqual(a,b) #a,b是否相等,不相等则报错
#self.assertNotEqual(a,b) #a,b不相等,则成功
def test_2(self):
aa=5
self.assertTrue(aa) #aa是True,则成功
#self.assertFalse(aa) #aa是False,则成功
def test_3(self):
aaa=‘a is a‘
bbb=‘a is b‘
#self.assertIs(aaa,bbb) #验证是同一对象
self.assertIsNot(aaa,bbb)
def test_4(self):
a4=""
#self.assertIsNone(a4) #验证是None
self.assertIsNotNone(a4) #验证不是None
def test_5(self):
a5=‘a is a common letter‘
b5=‘yis a common letter‘
#self.assertIn(b5,a5)#验证b5是a5的子串
self.assertNotIn(b5,a5,msg=‘b5 in a5‘) #验证b5不是a5的子串
if __name__=="__main__":
unittest.main()
标签:letter rtt let mon als == imp sel test
原文地址:https://www.cnblogs.com/canglongdao/p/11973513.html