首页 > 编程语言 > 详细

python模板:自动化执行测试函数

时间:2018-03-06 14:27:52      阅读:215      评论:0      收藏:0      [点我收藏+]
#!/bin/python
#example 1.1
#applay
def function(a,b):
    print(a,b)
def example1():
    apply(function, ("whither","cannada?"))
    apply(function, (1,2+3))

def example2():
    print("hell0 world")

def example4():
    print("hed")

if __name__ == "__main__":
    print("process %s section start" % "__builtin__")
    print("---")
    for i in xrange(1,1000):
        strFunctionName = "example%d" % i
        if strFunctionName in globals():
            strExcuteFunctionName = "%s()" % strFunctionName
            print("#excute function %s:" % strFunctionName)
            eval(str(strExcuteFunctionName),globals())
            print("---")
        else:
            break

    print("process end")

在脚本中书写example+数字的测试函数,脚本作为程序运行时会执行所有exmaple开头的函数

python模板:自动化执行测试函数

原文:https://www.cnblogs.com/zhangdewang/p/8513890.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!