コード例 #1
0
def test_hand_take_top_len_check_after_pop():
    """Hand len decreases after take_top"""
    hand = Hand()
    card1 = Card('H', '5')
    card2 = Card('S', 'J')
    hand.add_card(card1)
    hand.add_card(card2)
    hand.take_top()
    assert len(hand.cards) == 1
コード例 #2
0
def test_hand_take_top_has_only_1_card():
    """ Hand has only one card. take_top gives empty hand."""
    hand = Hand()
    card1 = Card('H', '5')
    hand.add_card(card1)
    top_card = hand.take_top()
    assert len(hand.cards) == 0
    assert str(top_card) == str(card1)
コード例 #3
0
def test_hand_take_top_check():
    """Take top card of hand"""
    hand = Hand()
    card1 = Card('H', '5')
    card2 = Card('S', 'J')
    hand.add_card(card1)
    hand.add_card(card2)
    top_card = hand.take_top()
    assert str(top_card) == str(card1)
コード例 #4
0
def test_hand_take_top_of_empty_hand():
    """Assert IndexError for empty hand, when take_top ran"""
    with pytest.raises(IndexError):
        hand = Hand()
        hand.take_top()