def test_sort_wrong_trump(self): """ Test hand sorting with wrong trump value """ deck = Deck() hands = deck.distribute() hand = Hand() hand.set(hands[0]) self.assertRaises(ValueError, hand.sort, 'trump')
def test_distribute_deck(self): """ Test deck distribution """ deck = Deck() hands = deck.distribute() for hand in hands: self.assertEqual(len(hand), 8) self.assertEqual(len(deck), 0)
def test_play_card(self): """ Test correct card played """ deck = Deck() hands = deck.distribute() hand = Hand() hand.set(hands[0]) hand.play(0) self.assertEqual(len(hand.get()), 7)
def test_create_hand(self): """ Test correct hand creation """ deck = Deck() hands = deck.distribute() hand = Hand() hand.set(hands[0]) self.assertEqual(hand.get(full=True), hands[0]) self.assertEqual(hand.get(full=False), hands[0])
def test_create_deck(self): """ Test deck creation """ deck = Deck() self.assertEqual(len(deck), 32) self.assertEqual(deck.get()[0].get_value(), 0) self.assertEqual(deck.get()[0].get_color(), 0) self.assertEqual(deck.get()[-1].get_value(), 7) self.assertEqual(deck.get()[-1].get_color(), 3)
def test_sort_hand(self): """ Test correct hand sorting """ deck = Deck() hands = deck.distribute() hand = Hand() hand.set(hands[0]) hand.sort(3) expected_hand = '[7 of Club, 8 of Club, 9 of Club, Jack of Diamond, Queen of Diamond, Queen of Spade, ' \ 'King of Spade, Jack of Spade]' self.assertEqual(str(hand), expected_hand)
def test_shuffle_deck(self): """ Test deck shuffle """ deck = Deck() previous_deck = deck.get() deck.shuffle() shuffled_deck = deck.get() same, i = True, 0 while same and i < 32: if previous_deck[i] != shuffled_deck[i]: same = False i += 1 self.assertEqual(same, False)
def __init__(self, players): player_names = ['Player0', 'Player1', 'Player2', 'Player3'] self.players = [ players[i](name=player_names[i], index=i) for i in range(4) ] self.teams = [ Team(self.players[0], self.players[2]), Team(self.players[1], self.players[3]) ] self.first_player = 0 self.deck = Deck() self.gui = None
def test_play_card_wrong_value(self): deck = Deck() hands = deck.distribute() hand = Hand() hand.set(hands[0]) self.assertRaises(ValueError, hand.play, 8)
def test_distribute_deck_wrong_two(self): """ Test distribution with wrong two value """ deck = Deck() self.assertRaises(ValueError, deck.distribute, 3)