Example #1
0
    def test_play_game_over(self):
        """Test that the game ends  when game_over is False."""
        mm = MasterMind(3)
        mm.display_game = MagicMock()
        mm.get_next_guess = MagicMock()
        mm.evaluate_guess = MagicMock()
        mm.update_points = MagicMock()
        mm.game_over = True

        mm.play()

        self.assertEqual(0, mm.display_game.call_count)
        self.assertEqual(0, mm.get_next_guess.call_count)
        self.assertEqual(0, mm.evaluate_guess.call_count)
        self.assertEqual(0, mm.update_points.call_count)
Example #2
0
    def test_play_game_over(self):
        """Test that the game ends  when game_over is False."""
        mm = MasterMind(3)
        mm.display_game = MagicMock()
        mm.get_next_guess = MagicMock()
        mm.evaluate_guess = MagicMock()
        mm.update_points = MagicMock()
        mm.game_over = True

        mm.play()

        self.assertEqual(0, mm.display_game.call_count)
        self.assertEqual(0, mm.get_next_guess.call_count)
        self.assertEqual(0, mm.evaluate_guess.call_count)
        self.assertEqual(0, mm.update_points.call_count)
Example #3
0
    def test_play(self):
        """Test that the  game continues when game_over is False."""
        mm = MasterMind(3)
        mm.display_game = MagicMock()
        mm.get_next_guess = MagicMock()
        mm.evaluate_guess = MagicMock()
        mm.update_points = MagicMock()
        mm.game_over = False

        def side_effect():
            mm.game_over = True
        mm.evaluate_guess.side_effect = side_effect

        mm.play()

        self.assertEqual(1, mm.display_game.call_count)
        self.assertEqual(1, mm.get_next_guess.call_count)
        self.assertEqual(1, mm.evaluate_guess.call_count)
        self.assertEqual(1, mm.update_points.call_count)
Example #4
0
    def test_play(self):
        """Test that the  game continues when game_over is False."""
        mm = MasterMind(3)
        mm.display_game = MagicMock()
        mm.get_next_guess = MagicMock()
        mm.evaluate_guess = MagicMock()
        mm.update_points = MagicMock()
        mm.game_over = False

        def side_effect():
            mm.game_over = True

        mm.evaluate_guess.side_effect = side_effect

        mm.play()

        self.assertEqual(1, mm.display_game.call_count)
        self.assertEqual(1, mm.get_next_guess.call_count)
        self.assertEqual(1, mm.evaluate_guess.call_count)
        self.assertEqual(1, mm.update_points.call_count)