Exemplo n.º 1
0
def test_guess_not_success():
    game = create_game()
    result = game.guess('d')
    assert not result
    assert game.guess_count == 1
    assert 'd' in game.guessed_letters
    assert game.get_current_state() == '_' * len(game.answer)
Exemplo n.º 2
0
def test_guess_success():
    game = create_game()
    answer = game.answer
    result = game.guess(answer[0])
    assert result
    assert game.guess_count == 0
    assert answer[0] in game.guessed_letters
    assert game.get_current_state().startswith(answer[0])
Exemplo n.º 3
0
def test_get_result_win(attempts_number):
    game = create_game()
    game.guess_count = attempts_number
    answer = game.answer
    game.guessed_letters = list(answer)
    assert game.get_result() == Result.WIN
Exemplo n.º 4
0
def test_get_result_continue(attempts_number):
    game = create_game()
    game.guess_count = attempts_number
    assert game.get_result() == Result.CONTINUE
Exemplo n.º 5
0
def test_get_result_fail(attempts_number):
    game = create_game()
    game.guess_count = attempts_number
    assert game.get_result() == Result.FAIL
Exemplo n.º 6
0
def test_guess_game_over():
    game = create_game()
    game.guess_count = MAX_AMOUNT_OF_ATTEMPS + 1
    with pytest.raises(ValueError):
        game.guess("a")
Exemplo n.º 7
0
def test_guess_not_a_letter():
    game = create_game()
    with pytest.raises(ValueError):
        game.guess("1")
Exemplo n.º 8
0
def test_create_game():
    game = create_game()
    assert game.answer in WORDS_LIST
    assert game.guess_count == 0
    assert game.guessed_letters == []