def test_play_game_fail(capsys): input_values = ['h', 'y', 'f', 'j', '0'] game_functions.WORDS_LIST = ['TESTING'] def spoof_input(prompt=None): if prompt: print(prompt, end='') return input_values.pop(0) game_functions.input = spoof_input game_functions.play_game() out, err = capsys.readouterr() assert out == ''.join([ '\n_ _ _ _ _ _ _ \n\nYour turn: ', '\nPenalty points: 1\n\nYour turn: ', '\nPenalty points: 2\n\nYour turn: ', '\nPenalty points: 3\n\nYour turn: ', '\nPenalty points: 4\n' '\nYou are loose. Try again!' '\nYou will be lucky next time!\n' '\nEnter 1 to start new game\n' 'Enter 2 to learn the rules\n' 'Enter 0 to exit\n' ]) assert err == ''
def test_play_game_win(capsys): input_values = ['t', 'E', 's', 'i', 'n', 'g', '0'] game_functions.WORDS_LIST = ['TESTING'] def spoof_input(prompt=None): if prompt: print(prompt, end='') return input_values.pop(0) game_functions.input = spoof_input game_functions.play_game() out, err = capsys.readouterr() assert out == ''.join([ '\n_ _ _ _ _ _ _ \n\nYour turn: ', '\nT _ _ T _ _ _ \n\nYour turn: ', '\nT E _ T _ _ _ \n\nYour turn: ', '\nT E S T _ _ _ \n\nYour turn: ', '\nT E S T I _ _ \n\nYour turn: ', '\nT E S T I N _ \n\nYour turn: ', '\nYou are win! Word is TESTING\n' '\nEnter 1 to start new game\n' 'Enter 2 to learn the rules\n' 'Enter 0 to exit\n' ]) assert err == ''
def test_play_game_invalid_input(capsys): input_values = ['t', 'yy', 'y', 'p', 'f', 'j', '0'] game_functions.WORDS_LIST = ['TESTING'] def spoof_input(prompt=None): if prompt: print(prompt, end='') return input_values.pop(0) game_functions.input = spoof_input game_functions.play_game() out, err = capsys.readouterr() assert out == ''.join([ '\n_ _ _ _ _ _ _ \n\nВаш ход: ', '\nT _ _ T _ _ _ \n\nВаш ход: ', 'Нет нет нет, только одна буква за ход!\n\nВаш ход: ', '\nШтрафные очки: 1\n\nВаш ход: ', '\nШтрафные очки: 2\n\nВаш ход: ', '\nШтрафные очки: 3\n\nВаш ход: ', '\nШтрафные очки: 4\n' '\nВы проиграли!💀\n' '\nНажмите 1, чтобы начать новую игру\n' 'Нажмите 2, чтобы узнать правила игры\n' 'Нажмите 0, чтобы выйти из игры\n' ]) assert err == ''
def test_play_game_win(capsys): input_values = ['t', 'E', 's', 'i', 'n', 'g', '0'] game_functions.WORDS_LIST = ['TESTING'] def spoof_input(prompt=None): if prompt: print(prompt, end='') return input_values.pop(0) game_functions.input = spoof_input game_functions.play_game() out, err = capsys.readouterr() assert out == ''.join([ '\n_ _ _ _ _ _ _ \n\nВаш ход: ', '\nT _ _ T _ _ _ \n\nВаш ход: ', '\nT E _ T _ _ _ \n\nВаш ход: ', '\nT E S T _ _ _ \n\nВаш ход: ', '\nT E S T I _ _ \n\nВаш ход: ', '\nT E S T I N _ \n\nВаш ход: ', '\nВы победили!🎉🎉🎉 Загаданное слово: TESTING\n' '\nНажмите 1, чтобы начать новую игру\n' 'Нажмите 2, чтобы узнать правила игры\n' 'Нажмите 0, чтобы выйти из игры\n' ]) assert err == ''
def main(): print("Welcome tho the Geo Quiz Game. \nWhat do you want to do?") while True: print("[P]lay \n[Q]uit") selection = input("Your choice? ").lower() if selection == "p": game_functions.play_game() elif selection == "q": print("Goodbye.") break else: print("Please enter a valid option. [P/Q]")