python 学徒活动1测试员(python)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 学徒活动1测试员(python)相关的知识,希望对你有一定的参考价值。

from apprentice_activities import *


def activity01test():
    tests = {2: 'Even', 17: 'Odd', 1: 'Odd', 5: 'Odd'}
    print "\nStarting Test 1..."
    for i in tests:
        return_string = activity01(i)
        if tests[i] != return_string:
            print "\n** Failed **\t Input: %d\tExpected: %s\tReceived: %s" % (i, tests[i], return_string)
            return -1
        else:
            print "Correct:\t%d\t\t=\t%s" % (i, return_string)
    return 0


def activity02test():
    tests = ([1, 2, 3], [4, 19, 23], [0, 0, 0], [3, 6, 9])
    print "\nStarting Test 2..."
    for i in tests:
        return_string = activity02(i[0], i[1])
        if return_string != i[2]:
            print "\n** Failed **\t Inputs: %d, %d\tExpected: %d\tRecieved: %d" % (i[0], i[1], i[2], return_string)
            return -1
        else:
            print "Correct:\t%d+%d\t\t=\t%d" % (i[0], i[1], i[2])
    return 0


def activity03test():
    tests = [[[1, 2, 3, 4], 2], [[1, 2, 5, 7], 1],
             [[2, 4, 6, 9], 3], [[1, 2, 6, 7], 2]]
    print "\nStarting Test 3..."
    for i in tests:
        return_value = activity03(i[0])
        if return_value != i[1]:
            print "\n** Failed **\t Inputs: %s\tExpected: %d\tReceived: %d" % (str(i[0]), i[1], return_value)
            return -1
        else:
            print "Correct:\t%s\t=\t%d" % (str(i[0]), return_value)
    return 0


def activity04test():
    tests = {'string': 'gnirts', 'racecar': 'racecar',
             'test': 'tset', 'success': 'sseccus'}
    print "\nStarting Test 4..."
    for i in tests:
        return_string = activity04(i)
        if tests[i] != return_string:
            print "\n** Failed **\t Input: %s\tExpected: %s\tReceived: %s" % (i, tests[i], return_string)
            return -1
        else:
            print "Correct:\t%s\t\t=\t%s" % (i, tests[i])
    return 0


def main():
    test_list = [activity01test(), activity02test(),
                 activity03test(), activity04test()]
    for i in test_list:
        if i != 0:
            return

main()

以上是关于python 学徒活动1测试员(python)的主要内容,如果未能解决你的问题,请参考以下文章

python 谷歌用户名测试员

40+岁老测试员生涯回顾,Python自动化从业十年是种什么体验?

40+岁老测试员生涯回顾,Python自动化从业十年是种什么体验?

40+岁老测试员生涯回顾,Python自动化从业十年是种什么体验?

40+岁老测试员生涯回顾,Python自动化从业十年是种什么体验?

python自动化测试高薪,写给准备转行的朋友:非科班出身,怎么成为测试员!