def test_game_finished(run, monkeypatch): monkeypatch.setattr( 'hangman.view.prompt_guess', Mock(side_effect=['H', 'A', 'N', 'G', 'M', 'N', KeyboardInterrupt])) monkeypatch.setattr('hangman.view.prompt_play_again', Mock(side_effect=[True, False])) assert run() == 'Have a nice day!'
def test_value_error(game, run, monkeypatch): monkeypatch.setattr('hangman.view.prompt_guess', Mock(side_effect=['1', 'A'])) game.hits = list('HNGMN') assert run() == 'Have a nice day!'
def test_keyboard_interupt(run, monkeypatch): monkeypatch.setattr('hangman.view.prompt_guess', Mock(side_effect=KeyboardInterrupt)) assert run() == 'Have a nice day!'
def test_game_lost(game, run, monkeypatch, flash): monkeypatch.setattr('hangman.view.prompt_guess', lambda: 'O') game.misses = list('BCDEFIJKL') assert run() == 'Have a nice day!' assert flash.game_lost is True
def test_game_won(game, run, flash): game.hits = list('HNGMN') assert run() == 'Have a nice day!' assert flash.game_won is True
def test_game_finished(run, monkeypatch): monkeypatch.setattr('hangman.view.prompt_guess', Mock(side_effect=['H', 'A', 'N', 'G', 'M', 'N', KeyboardInterrupt])) monkeypatch.setattr('hangman.view.prompt_play_again', Mock(side_effect=[True, False])) assert run() == 'Have a nice day!'