Exemplo n.º 1
0
    def test_get_gameover_screen(self):
        # Partitions
        # Coverage
        run_tests = testtools.run_function_tests
        game = hangman.Game('hangman')
        function = game.get_gameover_screen
        screen = r"""----------------------------------
|__|  /\  |\ | /**  |\/|  /\  |\ |
|  | /--\ | \| \__| |  | /--\ | \|
----------------------------------

o-----------------o
|  _ _ _ _ _ _ _  |
o-----------------o
[ Already Guessed ]
|                 |
o-----------------o

"""
        gameover = OrderedDict([
            ('win', 'You guessed the word: hangman'),
            ('lose', 'You lose. The word was: hangman')])
        cases = [{'args': [state]} for state in gameover.keys()]
        expectedv = [screen + text for text in gameover.values()]

        for result, message in run_tests(function, cases, expectedv):
            self.assertTrue(result, message)
Exemplo n.º 2
0
def test_custom_word_list():
    word_list = ['Foo', 'Bar', 'Baz']
    game = hangman.Game(word_list=word_list)
    # Asserting length, not the identity of game.word_list as I might be
    # converting the word list to a different data structure in the future
    assert len(game.word_list) == len(word_list)
    assert game.word in word_list
Exemplo n.º 3
0
    def test_get_screen(self):
        # Partitions
        # Coverage
        message = testtools.function_message
        game = hangman.Game('hangman')
        expected = r"""----------------------------------
|__|  /\  |\ | /**  |\/|  /\  |\ |
|  | /--\ | \| \__| |  | /--\ | \|
----------------------------------

o-----------------o
|  _ _ _ _ _ _ _  |
o-----------------o
[ Already Guessed ]
|                 |
o-----------------o"""
        actual = game.get_screen()
        self.assertTrue(expected == actual)
Exemplo n.º 4
0
import hangman
import sys

if __name__ == "__main__":
    ARGV = sys.argv

    if len(ARGV) == 1:
        use_argv = False
    else:
        use_argv = True

    if not use_argv:
        hangman.Game().play()
    else:
        tries = int(ARGV[1])
        word = str(ARGV[2])

        hangman.Game(word, tries).play()
Exemplo n.º 5
0
import hangman
import to_spec

game = hangman.Game()
game = to_spec.Game()

while True:
    game.iterate()
Exemplo n.º 6
0
import hangman
game = hangman.Game(word="EXAMPLE").play()
Exemplo n.º 7
0
def default_game():
    game = hangman.Game()
    return game
Exemplo n.º 8
0
def test_custom_guesses():
    game = hangman.Game(num_guesses=id(mock.sentinel.guess_count))
    assert game.num_guesses == id(mock.sentinel.guess_count)
Exemplo n.º 9
0
def game():
    game = hangman.Game(word_list=['FooBar'], num_guesses=4)
    return game