예제 #1
0
    def test_display_current_dice(self, mock_stdout):
        """Set values of die_a and die_b to some values.
        Call tested function, and check that the expected string was output."""

        self.new_angry_dice = AngryDice()

        self.new_angry_dice.die_a.current_value = "2"
        self.new_angry_dice.die_b.current_value = "5"

        expected_output = "You rolled:\n   a = [  2  ]\n   b = [  5  ]\n\n"
        self.new_angry_dice.display_current_dice()

        self.assertEqual(expected_output, mock_stdout.getvalue())

        del self.new_angry_dice
예제 #2
0
    def test_handle_angry_dice(self, mock_stdout):
        """Set values of die_a and die_b to "ANGRY" and game_stage to 2.
        Call tested function. Check that the game reset to stage 1, and that
        the expected string was output."""

        self.new_angry_dice = AngryDice()

        self.new_angry_dice.die_a.current_value = "ANGRY"
        self.new_angry_dice.die_b.current_value = "ANGRY"
        self.new_angry_dice.game_stage = 2

        expected_output = "WOW, you're ANGRY!\nTime to go back to Stage 1!\n"
        self.new_angry_dice.handle_angry_dice()

        self.assertEqual(expected_output, mock_stdout.getvalue())
        self.assertEqual(1, self.new_angry_dice.game_stage)

        del self.new_angry_dice
예제 #3
0
 def setUp(self):
     self.new_angry_dice = AngryDice()