Issue created as a suggestion of a unit test to implement for task B of the 12th exercise set.
Consider implementing a unit test for the chooseAction() method that makes sure that the user input held in the variable action is always handled. For instance, the current implementation would fail if the digit held in the variable action is not within the range of the array action_functions. The current implementation already checks whether the input is a digit - tests for the handling of types such as floats could also be implemented in the unit test.
|
action_functions = [add_questions,print_questions,take_quiz,quit] |
|
def chooseAction(): |
|
action = input('Please select your action: ') |
|
if not action.isdigit(): |
|
raise TypeError('Invalid input - please type in the INTEGER corresponding to your action of choice') |
|
action = int(action) |
|
action_functions[action]() |
Issue created as a suggestion of a unit test to implement for task B of the 12th exercise set.
Consider implementing a unit test for the
chooseAction()method that makes sure that the user input held in the variableactionis always handled. For instance, the current implementation would fail if the digit held in the variableactionis not within the range of the arrayaction_functions. The current implementation already checks whether the input is a digit - tests for the handling of types such as floats could also be implemented in the unit test.Quiz_MZimmerli/Quiz.py
Lines 159 to 165 in 6eccfd5