以这段代码为例。如何模拟我的代码成功进入主菜单?我现在这样做的方式是,代码只是贯穿整个程序,总是无法通过测试用例。
user_Response = input(
'\n' "○ Press 1 to Enter the Main Menu" '\n'
"○ Press 2 or type 'exit' to Exit \n ")
start(user_Response)
def start(user_ Response)
if user_Response == str(1):
mainMenu()
elif user_Response == str(2) or user_Response.lower() == "exit":
print(
'Thank you for stopping by today.
我试过了:
class TestMain(unittest.TestCase):
def test_start_1(self):
result = main.start('1')
self.assertEquals(result, main.mainMenu())
.非常新的单元测试