def test_2_AddAndRemove(self): card1 = mycard.Card(0, 1) my_hand = hands.Hand([card1]) card_toadd = mycard.Card(0, 6) my_hand.add_card(card_toadd) self.assertEqual(my_hand.cards[-1], card_toadd) card_removed = my_hand.remove_card(card1) self.assertEqual(card_removed, card1)
def testRemovePair(self): card1 = cards.Card(suit=1, rank=2) card2 = cards.Card(suit=2, rank=2) card3 = cards.Card(suit=3, rank=3) cards_in_hand = [card1, card2, card3] hand = hands2.Hand(cards_in_hand) hand.remove_pairs() self.assertEqual(len(hand.init_cards), 1)
def test_1_initial(self): # test the hand is correctly initialized with some cards card1 = mycard.Card(0, 1) card2 = mycard.Card(0, 2) card3 = mycard.Card(0, 3) init_list = [card1, card2, card3] my_hand = hands.Hand(init_list) for instance in my_hand.cards: self.assertIsInstance(instance, mycard.Card)
def test_8_not_effected(self): my_card = cards.Card() deck5 = cards.Deck() num_cards_initial = len(deck5.cards) deck5.replace_card(my_card) num_cards = len(deck5.cards) self.assertEqual(num_cards_initial, num_cards)
def test_8_replace_present_card(self): deck = cards.Deck() deck_len_problem_8_one = len(deck.cards) card = cards.Card(suit=3, rank=13) card_replace = deck.replace_card(card) deck_len_problem_8_two = len(deck.cards) self.assertEqual(deck_len_problem_8_one, deck_len_problem_8_two)
def test_3_king_of_spades(self): """ Test that if you invoke the __str__ method of a card instance that is created with: suit=3, rank=13, it returns the string "King of Spades" """ card = cards.Card(3, 13) self.assertEqual(card.__str__(), "King of Spades")
def test_5_deckcard(self): deck = cards.Deck() # Check last card of deck(specific) card_from_deck = deck.deal_card() self.assertEqual(card_from_deck.__str__(), "King of Spades") # Check the type of card(general) new_card = cards.Card() self.assertEqual(type(card_from_deck), type(new_card))
def test_8_deck(self): d4 = cards.Deck() lenght_first = len(d4.cards) c = cards.Card() d4.replace_card(c) length_last = len(d4.cards) #self.assertEqual(len(d4.cards),52) self.assertEqual(lenght_first, length_last)
def test_5_deal_card_return(self): """ Test that if you invoke the deal_card method on a deck, it will return a card instance. """ deck = cards.Deck() card = cards.Card(3, 13).__str__() dealt = deck.deal_card(i=-1).__str__() self.assertEqual(dealt, card)
def test_8_replace(self): """Test that if you invoke the replace_card method with a card that is already in the deck, the deck size is not affected.(The function must silently ignore it if you try to add a card that’s already in the deck) """ c8 = cards.Card() d8 = cards.Deck() num_deck = len(d8.cards) if c8 in d8.cards: d8.replace_card(c8) num_not_affected = len(d8.cards) self.assertEqual(num_deck, num_not_affected)
def test_8_already(self): # Test that if you invoke the replace_card method with a card that is already in the deck, the deck size is not affected. # (The function must silently ignore it if you try to add a card that's already in the deck) d4 = cards.Deck() primary_len = len(d4.cards) # 52 Total card = cards.Card(suit=3, rank=13) self.assertEqual(card.__str__(), d4.cards[-1].__str__()) # Check the card in the deck d4.replace_card(card) updated_len = len(d4.cards) self.assertEqual(primary_len, updated_len)
def test_8_already(self): deck = cards.Deck() original_len = len(deck.cards) # 52 card = cards.Card(suit=3, rank=13) self.assertEqual( card.__str__(), deck.cards[-1].__str__()) # Check the card in the deck deck.replace_card(card) new_len = len(deck.cards) self.assertEqual(original_len, new_len)
def testAddAndRemove(self): hand = hands.Hand([]) hand_len = len(hand.init_cards) card = cards.Card() hand.add_card(card) add_len = len(hand.init_cards) self.assertEqual(add_len - hand_len, 1) remcard = hand.remove_card(card) rem_len = len(hand.init_cards) if remcard is None: self.assertEqual(rem_len, add_len) else: self.assertEqual(rem_len + 1, add_len)
def test_3_KingofSpades(self): c3=cards.Card(3,13) self.assertEqual(c3.__str__(), "King of Spades")
def test_2_Clubs(self): c2=cards.Card(1) self.assertEqual(c2.suit_name, "Clubs")
def test_3_str(self): card = cards.Card(suit=3, rank=13) self.assertEqual(str(card), "King of Spades")
def test_5_dealcardmethod(self): deck = cards.Deck() deal = deck.deal_card() self.assertEqual(type(deal), type(cards.Card()))
def test_5_invoke(self): d1 = cards.Deck() m_card = cards.Card() self.assertEqual(type(d1.deal_card()), type(m_card))
def test_2_club(self): card = cards.Card(suit=1) self.assertEqual(card.suit_name, "Clubs")
def test_3_str(self): card = cards.Card(3, 13) self.assertEqual(str(card), "King of Spades")
def test_3_king_of_spades(self): card = cards.Card(suit=3, rank=13) self.assertEqual(card.__str__(), "King of Spades")
def test_2_clubs(self): """Test that if you create a card instance with suit 1, its suit_name will be "Clubs" """ c2 = cards.Card(suit=1) self.assertEqual(c2.suit_name, "Clubs")
def test_1_queen(self): """Test that if you create a card with rank 12, its rank_name will be "Queen" """ card = cards.Card(rank=12) self.assertEqual(card.rank_name, "Queen")
def test_0_create(self): card = cards.Card() self.assertEqual(card.suit_name, "Diamonds") self.assertEqual(card.rank, 2)
def test_1_queen(self): card = cards.Card(rank=12) self.assertEqual(card.rank_name, "Queen")
def test_5_card(self): deck = cards.Deck() card = cards.Card() self.assertEqual(type(deck.deal_card()), type(card))
def test_3_invoke(self): card = cards.Card(suit=3, rank=13) #print(card) self.assertEqual(str(card), "King of Spades")
def test_3_string(self): card3 = cards.Card(3, 13) self.assertEqual(card3.__str__(), "King of Spades")
def test_2_suit(self): card = cards.Card(1, 0) self.assertEqual(card.suit_name, "Clubs")
def test_2_cardistance(self): card = cards.Card(suit=1) self.assertEqual(card.suit_name, 'Clubs')