def test_get_cards_from_ranks(self): deck = init_54_deck() player = Player(0) player.hand = deck test_ranks = ['A', '2', '3'] chosen_cards, remained_cards = get_cards_from_ranks(player, test_ranks) self.assertEqual(len(chosen_cards), 12) for card in chosen_cards: flag = True if card.rank in test_ranks: flag = False self.assertFalse(flag) self.assertEqual(len(remained_cards), len(deck) - 12) self.assertEqual(len(chosen_cards), 12)
def init_players(n): ''' Initilize a list of Player objects with n players Args: n (int): The number of players to be initialized Returns: (list): A list of Player objects with player_id(s) start from 0 and are consequent ''' players = [] for idx in range(n): players.append(Player(idx)) return players