def test_set_name(self): original_player_name = "Test" new_player_name = "Bob" player = Player(original_player_name) self.assertEqual(player.name, original_player_name) player.set_name(new_player_name) self.assertEqual(player.name, new_player_name)
def create_players(player_count: int) -> List[Player]: """Create a list of players according to count return: list of Players """ player_list = [] for n in range(player_count): player_list.append(Player(f"Player{n}")) return player_list
def test_add_players(self): game = War() p1 = Player("One", 1) p2 = Player("Two", 2) p3 = Player("Three", 3) game.add_player(p1) self.assertIn(p1.id(), game._player_order) self.assertIs(p1, game._players[p1.id()]['player']) game.add_player(p2) self.assertIn(p2.id(), game._player_order) self.assertIs(p2, game._players[p2.id()]['player']) game.add_player(p3) self.assertNotIn(p3.id(), game._player_order) self.assertEqual(2, len(game._players))
def test_set_human(self): player = Player("CPU") self.assertEqual(player.human, 0) player.set_human() self.assertEqual(player.human, 1)