def main(): """ Call all functions to run the program. """ inventory = ['Longsword', 'Dagger', 'Bow', 'Staff', 'Wand', 'Shield', 'Spear', 'Axe', 'Hammer'] print("I am now rolling a 3d6 ---> You rolled", roll_die(3, 6)) print("I am now generating two random inventory items for you ---> ", choose_inventory(inventory, 2)) print("I am now generating your name ---> Hello", generate_name(4)) print("I am now creating a random character for you ---> ", create_character(8)) print("\n..... Here is your character info below .....") character = create_character(8) character.append(choose_inventory(inventory, 3)) print_character(character)
def test_choose_inventory_first(self, mock_output): inventory_test = ['one', 'two', 'three', 'four'] expected_value = [1, 2] actual_value = choose_inventory(inventory_test, 2) self.assertEqual(actual_value, expected_value)
def test_choose_inventory_selection_positive(self, mock_choices): actual = choose_inventory(['Sword', 'Shield', 'Bow'], 2) expected = ['Shield', 'Sword'] self.assertEqual(expected, actual)
def test_choose_inventory_empty_list_selection_zero(self, mock_choices): actual = choose_inventory([], 0) expected = [] self.assertEqual(expected, actual)
def test_choose_inventory_selection_equal_to_list_length( self, mock_choices): actual = choose_inventory(['Sword', 'Shield', 'Bow'], 3) expected = ['Bow', 'Shield', 'Sword'] self.assertEqual(expected, actual)
def test_choose_inventory_selection_greater_than_list_length_return_value( self, mock_choices): actual = choose_inventory(['Sword', 'Shield', "Bow"], 4) expected = ['Bow', 'Shield', 'Sword'] self.assertEqual(expected, actual)
def test_choose_inventory_selection_greater_than_list_length_stdout( self, mock_stdout): choose_inventory(['Sword', 'Shield', "Bow"], 4) actual = mock_stdout.getvalue() expected = "Your selection is greater than the amount of items in the inventory.\n" self.assertEqual(expected, actual)
def test_choose_inventory_selection_negative_return_value( self, mock_choices): actual = choose_inventory(['Sword', 'Shield', "Bow"], -1) expected = [] self.assertEqual(expected, actual)
def test_choose_inventory_selection_negative_stdout(self, mock_stdout): choose_inventory(['Sword', 'Shield', "Bow"], -1) actual = mock_stdout.getvalue() expected = "You can't make a negative selection!\n" self.assertEqual(expected, actual)