コード例 #1
0
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!'
コード例 #2
0
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!'
コード例 #3
0
def test_keyboard_interupt(run, monkeypatch):
    monkeypatch.setattr('hangman.view.prompt_guess',
                        Mock(side_effect=KeyboardInterrupt))

    assert run() == 'Have a nice day!'
コード例 #4
0
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
コード例 #5
0
def test_game_won(game, run, flash):
    game.hits = list('HNGMN')

    assert run() == 'Have a nice day!'
    assert flash.game_won is True
コード例 #6
0
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!'
コード例 #7
0
def test_keyboard_interupt(run, monkeypatch):
    monkeypatch.setattr('hangman.view.prompt_guess', Mock(side_effect=KeyboardInterrupt))

    assert run() == 'Have a nice day!'
コード例 #8
0
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!'
コード例 #9
0
def test_game_won(game, run, flash):
    game.hits = list('HNGMN')

    assert run() == 'Have a nice day!'
    assert flash.game_won is True
コード例 #10
0
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