Exemple #1
0
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)
Exemple #2
0
def test_pack_shuffling():
    a = Pack()
    b = Pack()

    init_pack(a)
    init_pack(b)

    # Something fishy around here. This should fail as it is.
    # Have to inspect __eq__ in pack and card.
    #card = Card(1,'a')

    # a.put_card(card)
    # b.put_card(card)

    assert_equal(a, b)

    shuffle_pack(a)

    # assert_true(a == b)

    # Shuffling a pack should (usually) give a differently ordered aepack
    assert_not_equal(a, b)
def test_player_hitting():
    p = Player('Fooman')
    h = Hand()
    pack = Pack()
    #    length = len(pack)

    init_pack(pack)
    p.hand_list.append(h)

    p.hit(pack)

    assert_true(len(p.hand_list[0]) == 1 and len(pack) == 51)

    hit_20_cards(p, pack)

    # Should bust from hitting 20 cards.
    assert_true(busted(p.hand_list[0], Rules()))
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)
Exemple #5
0
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():
    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])