Пример #1
0
def main():
    parser = argparse.ArgumentParser(description='hangman game')
    parser.add_argument('--dict', type=str, required=False, default='dict.txt',
                        help='path to dictionary, file with words')

    args = parser.parse_args()
    game = Game(words_path=args.dict)
    game.start_game()
Пример #2
0
def test_win():
    """
    Checks win scenario
    """
    game = Game()
    game.words = ['game']
    game.pick_random()
    game.input_stream = [
        'a',
        'g',
        'm',
        'e',
    ]
    check = game.start_game()
    assert check
    assert ''.join(game.guess_word) == 'game'
Пример #3
0
def test_fail():
    """
    Checks lose scenario
    """
    game = Game()
    game.words = ['game']
    game.pick_random()
    game.input_stream = [
        'a',
        'g',
        'm',
        'b',
        'c',
        'd',
        'f',
        'i',
    ]
    check = game.start_game()
    assert not check
    assert ''.join(game.guess_word) == 'gam*'