示例#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)
示例#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])
示例#3
0
文件: digin.py 项目: alfredgg/digin
def create_digin_game():
    deck = choose_existent_deck()
    create_game(deck.id, MODE_FRONT2REVER)
示例#4
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
示例#5
0
def test_get_result_continue(attempts_number):
    game = create_game()
    game.guess_count = attempts_number
    assert game.get_result() == Result.CONTINUE
示例#6
0
def test_get_result_fail(attempts_number):
    game = create_game()
    game.guess_count = attempts_number
    assert game.get_result() == Result.FAIL
示例#7
0
def test_guess_game_over():
    game = create_game()
    game.guess_count = MAX_AMOUNT_OF_ATTEMPS + 1
    with pytest.raises(ValueError):
        game.guess("a")
示例#8
0
def test_guess_not_a_letter():
    game = create_game()
    with pytest.raises(ValueError):
        game.guess("1")
示例#9
0
def test_create_game():
    game = create_game()
    assert game.answer in WORDS_LIST
    assert game.guess_count == 0
    assert game.guessed_letters == []