def test_generate_character_correct_keys(self, mock_select_class): character = dungeonsanddragons.generate_character(2) character_keys = [ "Name", "Class", "HP", "Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma", "XP", "Inventory" ] for key in character.keys(): self.assertIn(key, character_keys)
def test_generate_character_charisma_within_boundaries( self, mock_select_class): character = dungeonsanddragons.generate_character(2) self.assertTrue(3 <= character["Charisma"] <= 18)
def test_generate_character_with_empty_str(self): with self.assertRaises(TypeError): dungeonsanddragons.generate_character("")
def test_generate_character_syllable_less_or_equal_0_expected_output( self, mock_select_class, mock_stdout): expected_output = "syllables must be a positive integer!\n" dungeonsanddragons.generate_character(-4) self.assertEqual(mock_stdout.getvalue(), expected_output)
def test_generate_character_syllable_less_than_0(self, mock_select_class): self.assertEqual(dungeonsanddragons.generate_character(-2), None)
def test_generate_character_type(self, mock_select_class): self.assertIsInstance(dungeonsanddragons.generate_character(3), dict)