コード例 #1
0
 def test_attack_min_print(self, mock_randint, mock_stdout):
     expected = '\ntest dealt 1 damage!\ntest has 1 HP left.\n'
     attack(
         {
             'Name': "test",
             'Race': "test",
             'Class': "wizard",
             'HP': [1, 1],
             'Strength': 1,
             'Dexterity': 1,
             'Constitution': 1,
             'Intelligence': 1,
             'Wisdom': 1,
             'Charisma': 1,
             'XP': 0,
             'Inventory': []
         }, {
             'Name': "test",
             'Race': "test",
             'Class': "wizard",
             'HP': [2, 2],
             'Strength': 1,
             'Dexterity': 1,
             'Constitution': 1,
             'Intelligence': 1,
             'Wisdom': 1,
             'Charisma': 1,
             'XP': 0,
             'Inventory': []
         })
     actual = mock_stdout.getvalue()
     self.assertEqual(expected, actual)
コード例 #2
0
    def test_attack_with_less_damage_than_defender_hp(self, mock_randint,
                                                      mock_stdout):
        """Test attack function when damage is less than defender's hp.

        The result is expected to print out the same as expected_output
        """
        dungeonsanddragons.attack(self.attacker, self.defender)
        expected_output = "codeky rolled 20\n" \
                          "riqozi's dex : 13\n" \
                          "codeky damaged 1 to riqozi\n" \
                          "riqozi's hp : 1\n"
        self.assertEqual(mock_stdout.getvalue(), expected_output)
コード例 #3
0
    def test_attack_with_False(self, mock_can_attack):
        """Test attack function when can_attack function returns False.

        The result is expected to return None
        """
        self.assertIsNone(
            dungeonsanddragons.attack(self.attacker, self.defender))
コード例 #4
0
 def test_attack(self, mock_class, mock_race):
     char_one = create_character(4)
     char_two = create_character(4)
     actual_value = attack(char_one, char_two)