[ create a new paste ] login | about

Link: http://codepad.org/IMfqTZZT    [ raw code | output | fork ]

grrussel - Python, pasted on Jan 31:
def test_function1():
    # Do some test code
    # return True on Pass, False on Fail
    return True

def test_function2_EXPECTED_FAIL():
    # Do some test (more) code
    # return True on Pass, False on Fail
    return False
    
def test_functionN():
    # Do some test (more) code
    # return True on Pass, False on Fail
    return False
    
# Build a list of test functions to run
# as test cases
tests = [ test_function1
        , test_function2_EXPECTED_FAIL
        #, ...
        , test_functionN
        ]

def main():
    failed  = []
    # Invoke each test case in turn
    for t in tests:
        if not t():
            # Can check names of test functions 
            # to detect expected fails
            if t.__name__.endswith("_EXPECTED_FAIL"):
                continue
            # Record fails for later report
            failed.append(t.__name__)
            # Can stop on 1st fail if desired
            # return 1
    # Print the list of tests that failed, if any
    for f in failed:
        print "FAIL:",f
        
# Invoke the test runner if run as script
# if __name__ == "__main__":

# Rum main directly here for codepad.org !
main()


Output:
1
FAIL: test_functionN


Create a new paste based on this one


Comments: