Skip to content

Unit test for method chooseAction #1

Description

@slerknes

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.

Quiz_MZimmerli/Quiz.py

Lines 159 to 165 in 6eccfd5

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]()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions