Esempio n. 1
0
    def test_win(self):
        word_list = []
        game = start_new_game(word_list, 'cat')

        guess_letter(game, 'c')
        self.assertEqual(
            _check_game_over(game['answer_word'], game['masked_word'],
                             game['remaining_misses']), False)

        guess_letter(game, 'a')
        self.assertEqual(
            _check_game_over(game['answer_word'], game['masked_word'],
                             game['remaining_misses']), False)

        guess_letter(game, 'b')
        self.assertEqual(
            _check_game_over(game['answer_word'], game['masked_word'],
                             game['remaining_misses']), False)

        guess_letter(game, 't')
        self.assertEqual(
            _check_game_over(game['answer_word'], game['masked_word'],
                             game['remaining_misses']), True)
        self.assertEqual(_check_win(game['answer_word'], game['masked_word']),
                         True)

        expected = {
            'answer_word': 'cat',
            'masked_word': 'cat',
            'previous_guesses': 'cabt',
            'remaining_misses': 4
        }
        self.assertEqual(game, expected)
Esempio n. 2
0
    def test_lose(self):
        word_list = []
        game = start_new_game(word_list, 'house')

        guess_letter(game, 'a')
        self.assertEqual(
            _check_game_over(game['answer_word'],
                             game['masked_word'],
                             game['remaining_misses']),
            False)

        guess_letter(game, 'b')
        self.assertEqual(
            _check_game_over(game['answer_word'],
                             game['masked_word'],
                             game['remaining_misses']),
            False)

        guess_letter(game, 'c')
        self.assertEqual(
            _check_game_over(game['answer_word'],
                             game['masked_word'],
                             game['remaining_misses']),
            False)

        guess_letter(game, 'd')
        self.assertEqual(
            _check_game_over(game['answer_word'],
                             game['masked_word'],
                             game['remaining_misses']),
            False)

        guess_letter(game, 'e')
        self.assertEqual(
            _check_game_over(game['answer_word'],
                             game['masked_word'],
                             game['remaining_misses']),
            False)

        guess_letter(game, 'f')
        self.assertEqual(
            _check_game_over(game['answer_word'],
                             game['masked_word'],
                             game['remaining_misses']),
            True)
        self.assertEqual(_check_lose(game['remaining_misses']), True)

        expected = {
            'answer_word': 'house',
            'masked_word': '****e',
            'previous_guesses': 'abcdef',
            'remaining_misses': 0
        }
        self.assertEqual(game, expected)
Esempio n. 3
0
 def test_check_game_over_false(self):
     self.assertEqual(_check_game_over('cat', '**t', 4), False)
Esempio n. 4
0
 def test_check_game_over_true_lose(self):
     self.assertEqual(_check_game_over('cat', 'c**', 0), True)
Esempio n. 5
0
 def test_check_game_over_true_win(self):
     self.assertEqual(_check_game_over('cat', 'cat', 3), True)