I am new to python. I want to test a function that takes raw inputs and calls another function base on the input. I know this can be tested using mock, but I don't know how.
My function is like this:
def show_main_menu(self):
"""shows main menu to user"""
print '1:create account \t 2:Log in \t any other to exit \n'
while True:
try:
option = int(raw_input('Enter your option: \t'))
except ValueError:
print 'please enter valid input \n'
continue
else:
break
if option == 1:
self.add_account()
print '\n ***successfully created account***\n'
self.menu_post_transaction()
elif option == 2:
self.login()
else:
print 'Thank you for using our services'
exit()
How can I test this function using unittest
?