unittest断⾔asrtEqualasrtInasrtTrue import unittest
# asrtEqual asrtIn asrtTrue
class Test(unittest.TestCa):
def testA(lf):
'''判断a == b'''
a =1
b =1
公务员面试时间lf.asrtEqual(a,b)
def testB(lf):
'''判断a in b'''
a ="hi!"
马卉
接力赛作文b ="hi! leihao"
lf.asrtIn(a,b)
def testC(lf):
'''判断a is True'''
a =True
lf.asrtTrue(a)
def testD(lf):
'''失败案例'''
a ="aaa"
b ="bbb"
lf.asrtEqual(a,b)
if __name__ =="__main__":中国童话故事大全
unittest.main()作业没写检讨书
第四个失败案例
常⽤断⾔:
1).asrtEqual(lf, first, cond,msg=None)
–判断两个参数相等:first == cond
2).asrtNotEqual(lf, first, cond,msg=None)
–判断两个参数不相等:first != cond
3).asrtIn(lf, member, container,msg=None)
–判断是字符串是否包含:member in container
4).asrtNotIn(lf, member,container, msg=None)挤密桩
小猪猪图片可爱–判断是字符串是否不包含:member not in container
5).asrtTrue(lf, expr, msg=None)
–判断是否为真:expr is True
6).asrtFal(lf, expr, msg=None)诚实守信演讲稿
–判断是否为假:expr is Fal
7).asrtIsNone(lf, obj, msg=None)
–判断是否为None:objis None
8).asrtIsNotNone(lf, obj,msg=None)
–判断是否不为None:obj is not None