Example #1
0
def broken_user_input_test():
    suite = finalexam.Suite("Testing broken user input...")
    runner = finalexam.Runner()

    # Make sure an exception is thrown if no tests are added to the suite.
    with finalexam.expect(ValueError):
        runner.run(suite)

    # Make sure only functions with one or two arguments can be used as tests.
    with finalexam.expect(ValueError):
        suite.test(illegal_test_function)

    # Make sure an exception is thrown if a helper can't be instantiated.
    with finalexam.expect(ValueError):
        suite.helper(IllegalCustomHelper)
        suite.test(print_status)
        runner.run(suite)
Example #2
0
def expected_error_test():
    with finalexam.expect(ZeroDivisionError):
        raise ZeroDivisionError

    with finalexam.expect(OverflowError):
        raise OverflowError

    with finalexam.expect(AssertionError):
        with finalexam.expect(ValueError):
            pass

    with finalexam.expect(KeyError):
        with finalexam.expect(AttributeError):
            raise KeyError
Example #3
0
def test_3():
    with finalexam.expect(ZeroDivisionError):
        undefined = 1 / 0
    time.sleep(1)
Example #4
0
def test_3():
    with finalexam.expect(ZeroDivisionError):
        undefined = 1 / 0
    time.sleep(1)