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)
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
def test_3(): with finalexam.expect(ZeroDivisionError): undefined = 1 / 0 time.sleep(1)