''' DS2000 Spring 2020 Sample code from class -- testing the ACT function in a better way Instead of manually running a driver over and over, we use this test suite to call our function over and over and compare the output to what we expected it to be. ''' # structure is: FROM module IMPORT funcname # the module act would be a file named act.py # Python looks in the current directory, or in the Python library from act import update_act def test_update_act(curr_act, num_students, new_score, expected): ''' Function test_update_act Input: values to pass to update_act function for ONE test -- curr_act (float), num_students (int), new_score (int). Also a float for the expected output Returns: nothing Does: Calls update_act with the given input, prints the actual result so it can be compared to the expected. ''' print('Testing inputs:', curr_act, ', ', num_students, ', ', new_score, '. Expecting new ACT: ', expected, sep = '') actual = update_act(curr_act, num_students, new_score) print('...actual result:', actual, '\n') def main(): # Test One: 0.0 avg, 0 students, get a 36. New ACT average -- 36 test_update_act(0.0, 0, 36, 36) # Test Two: 25 avg, 1 student, get a 15. New ACT average -- 20.0 test_update_act(25, 1, 15, 20.0) # Test Three: 25 avg, 20 students, get a 30. New ACT average -- 25.23. test_update_act(25, 20, 30, 25.23) # Test Four: 34 avg, 100 students, get a 34. New ACT average -- 34 test_update_act(34, 100, 34, 34) main()