def test_pack(): pack = Pack() card1, card2, card3 = create_some_cards() # Empty packs are empty assert_equal(len(pack), 0) # Can't get cards from an empty pack assert_raises(IndexError, pack.draw_card) # Putting cards to a pack pack.put_card(card1) assert_equal(len(pack), 1) pack.put_card(card2) assert_equal(len(pack), 2) # If we draw a card it should be the same card we just put in. assert_equal(pack.draw_card(), card2) # Only one card should remain assert_equal(len(pack), 1) pack.put_card(card1) pack.put_card(card2) pack.put_card(card3) # Drawing cards from a pack cards = pack.draw_card(3) # Cards come out of the pack in the reverse order we put them in. assert_equal(cards, [card3, card2, card1])
def test_pack_equality(): a = Pack() b = Pack() # What's the difference with these two? assert_true(a == b) assert_equal(a, b) assert_is_not(a, b) c1, c2, c3 = create_some_cards() a.put_card(c1) assert_false(a == b) b.put_card(c3) assert_true(a == b) assert_equal(a, b) a.put_card(c2)