Exemplo n.º 1
0
    def test_display_game_over_win(self, mock_raw_input):
        """Test that the right message is displayed on a win."""
        mm = MasterMind(4)
        mm.winner = True
        mm.save_score = MagicMock()

        mm.display_game_over()

        expected = [call('enter your initials:\n'),
                    call('Would you like to see the high scores? [y/N]\n'),
                    call().__eq__('y')]

        mock_raw_input.assert_called_with(expected)
Exemplo n.º 2
0
    def test_display_game_over_win(self, mock_raw_input):
        """Test that the right message is displayed on a win."""
        mm = MasterMind(4)
        mm.winner = True
        mm.save_score = MagicMock()

        mm.display_game_over()

        expected = [
            call('enter your initials:\n'),
            call('Would you like to see the high scores? [y/N]\n'),
            call().__eq__('y')
        ]

        mock_raw_input.assert_called_with(expected)
Exemplo n.º 3
0
    def test_evaluate_guess_win(self):
        """Test 4 matches in wrong spots."""
        guess = Guess('rgby')
        mm = MasterMind(8)
        mm.secret = 'rgby'
        mm.guesses.append(guess)
        mm.display_game_over = MagicMock()

        mm.evaluate_guess()

        self.assertTrue(mm.game_over)
        self.assertTrue(mm.winner)
Exemplo n.º 4
0
    def test_evaluate_guess_win(self):
        """Test 4 matches in wrong spots."""
        guess = Guess('rgby')
        mm = MasterMind(8)
        mm.secret = 'rgby'
        mm.guesses.append(guess)
        mm.display_game_over = MagicMock()

        mm.evaluate_guess()

        self.assertTrue(mm.game_over)
        self.assertTrue(mm.winner)