Exemplo n.º 1
0
 def test_displaying_word(self):
     game = HangmanGame('word')
     game.event('w')
     game.event('r')
     board = game.draw_board()
     _msg, word, _guesses, _prompt, _end = board.split("\n")
     self.assertEqual(word, "Word: w_r_")
Exemplo n.º 2
0
    def test_displaying_guesses(self):
        game = HangmanGame('word')
        game.event('w')
        board = game.draw_board()
        msg, _word, _guesses, _prompt, _end = board.split("\n")
        self.assertEqual(msg, "Word contains at least one 'w'! :D")

        game.event('w')
        board = game.draw_board()
        msg, _word, _guesses, _prompt, _end = board.split("\n")
        self.assertEqual(msg, "You've already guessed 'w'.")

        game.event('x')
        board = game.draw_board()
        msg, _word, _guesses, _prompt, _end = board.split("\n")
        self.assertEqual(msg, "Word contains no 'x'. :(")
Exemplo n.º 3
0
    def test_displaying_guesses(self):
        game = HangmanGame('word')
        game.event('w')
        board = game.draw_board()
        msg, _word, _guesses, _prompt, _end = board.split("\n")
        self.assertEqual(msg, "Word contains at least one 'w'! :D")

        game.event('w')
        board = game.draw_board()
        msg, _word, _guesses, _prompt, _end = board.split("\n")
        self.assertEqual(msg, "You've already guessed 'w'.")

        game.event('x')
        board = game.draw_board()
        msg, _word, _guesses, _prompt, _end = board.split("\n")
        self.assertEqual(msg, "Word contains no 'x'. :(")
Exemplo n.º 4
0
 def test_displaying_word(self):
     game = HangmanGame('word')
     game.event('w')
     game.event('r')
     board = game.draw_board()
     _msg, word, _guesses, _prompt, _end = board.split("\n")
     self.assertEqual(word, "Word: w_r_")
Exemplo n.º 5
0
 def test_draw_board(self):
     game = HangmanGame('word')
     board = game.draw_board()
     msg, word, guesses, prompt, end = board.split("\n")
     self.assertEqual(msg, "New game!")
     self.assertEqual(word, "Word: ____")
     self.assertEqual(guesses, "Letters guessed so far: ")
     self.assertEqual(prompt, "Enter next guess (0 to quit):")
Exemplo n.º 6
0
 def test_draw_board(self):
     game = HangmanGame('word')
     board = game.draw_board()
     msg, word, guesses, prompt, end = board.split("\n")
     self.assertEqual(msg, "New game!")
     self.assertEqual(word, "Word: ____")
     self.assertEqual(guesses, "Letters guessed so far: ")
     self.assertEqual(prompt, "Enter next guess (0 to quit):")
Exemplo n.º 7
0
 def test_draw_board_at_end_of_game(self):
     game = HangmanGame('m')
     game.event('m')
     board = game.draw_board()
     msg, word, guesses, prompt, end = board.split("\n")
     self.assertEqual(msg, "Flawless victory!")
     self.assertEqual(word, "Word: m")
     self.assertEqual(guesses, "Letters guessed so far: m")
     self.assertEqual(prompt, "Enter anything to start a new game"
                      " (0 to quit):")
Exemplo n.º 8
0
 def test_draw_board_at_end_of_game(self):
     game = HangmanGame('m')
     game.event('m')
     board = game.draw_board()
     msg, word, guesses, prompt, end = board.split("\n")
     self.assertEqual(msg, "Flawless victory!")
     self.assertEqual(word, "Word: m")
     self.assertEqual(guesses, "Letters guessed so far: m")
     self.assertEqual(prompt, "Enter anything to start a new game"
                              " (0 to quit):")
Exemplo n.º 9
0
 def test_exit(self):
     game = HangmanGame('elephant')
     game.event('0')
     self.assertEqual(game.exit_code, game.DONE)
     self.assertEqual(game.draw_board(), "Adieu!")
Exemplo n.º 10
0
 def test_exit(self):
     game = HangmanGame('elephant')
     game.event('0')
     self.assertEqual(game.exit_code, game.DONE)
     self.assertEqual(game.draw_board(), "Adieu!")