Exemple #1
0
def test_move_with_non_top_ace_throws_error():
	game = Game(no_shuffle=True)
	game.deal()
	game.draw()
	game.draw()

	with assert_raises(ValueError):
		game.move_card('as')
def test_quit_ends_game():
	out = StringIO()
	game = Game(out=out, no_shuffle=True)
	game.deal()

	game.quit()
	output = out.getvalue()[-22:]

	assert_equal(0, len(game.piles))
Exemple #3
0
def test_deal_sets_card_pile_numbers():
	game = Game(no_shuffle=True)

	game.deal()

	for i, pile in enumerate(game.piles):
		for j, card in enumerate(pile._cards):
			assert_equal(i, card.pile_number)
			assert_equal(j, card.pile_index)
Exemple #4
0
def test_quit_ends_game():
    out = StringIO()
    game = Game(out=out, no_shuffle=True)
    game.deal()

    game.quit()
    output = out.getvalue()[-22:]

    assert_equal(0, len(game.piles))
def test_draw_flips_one_card_from_draw_pile_to_discard_pile():
	out = StringIO()
	game = Game(out=out, no_shuffle=True)
	game.deal()
	expected_draw_pile_size = len(game.piles[0]) - 1

	game.draw()

	assert_equal(expected_draw_pile_size, len(game.piles[0]))
	assert_equal(1, len(game.piles[1]))
	assert_true(game.piles[1][0].is_face_up())
def test_deal():
	out = StringIO()
	game = Game(out=out, no_shuffle=True)
	game.deal()

	assert_equal(13, len(game.piles))
	assert_equal(24, len(game.piles[0]))
	for i, pile in enumerate(game.piles[1:6]):
		assert_equal(0, len(pile))
	for i, pile in enumerate(game.piles[6:]):
		assert_equal(i + 1, len(pile))
Exemple #7
0
def test_draw_flips_one_card_from_draw_pile_to_discard_pile():
    out = StringIO()
    game = Game(out=out, no_shuffle=True)
    game.deal()
    expected_draw_pile_size = len(game.piles[0]) - 1

    game.draw()

    assert_equal(expected_draw_pile_size, len(game.piles[0]))
    assert_equal(1, len(game.piles[1]))
    assert_true(game.piles[1][0].is_face_up())
Exemple #8
0
def test_deal():
    out = StringIO()
    game = Game(out=out, no_shuffle=True)
    game.deal()

    assert_equal(13, len(game.piles))
    assert_equal(24, len(game.piles[0]))
    for i, pile in enumerate(game.piles[1:6]):
        assert_equal(0, len(pile))
    for i, pile in enumerate(game.piles[6:]):
        assert_equal(i + 1, len(pile))
Exemple #9
0
def test_move_card_with_valid_move_of_ace_to_suit_pile():
	game = Game(no_shuffle=True)
	game.deal()

	game.move_card('ac')

	assert_equal(1, len(game.piles[2]))
	assert_equal(5, len(game.piles[11]))
	card = game.piles[2][0]
	assert_true(card.is_face_up())
	assert_equal(2, card.pile_number)
	assert_equal(0, card.pile_index)
def test_new_game_prints_board():
	new_board = """
24--- \033[31;40m|___|\033[0m       \033[37;40m|___|\033[0m \033[37;40m|___|\033[0m \033[37;40m|___|\033[0m \033[37;40m|___|\033[0m

0---- 1---- 2---- 3---- 4---- 5---- 6----
\033[31;47m K d \033[0m \033[31;47m 6 d \033[0m \033[30;47m K c \033[0m \033[30;47m 8 c \033[0m \033[30;47m 4 c \033[0m \033[30;47m A c \033[0m \033[31;47m Q h \033[0m

"""
	out = StringIO()
	game = Game(out=out, no_shuffle=True)
	slice_start = 0
	slice_end = min((slice_start + 9), len(new_board))

	game.deal()
	output = out.getvalue()
Exemple #11
0
def test_new_game_prints_board():
    new_board = """
24--- \033[31;40m|___|\033[0m       \033[37;40m|___|\033[0m \033[37;40m|___|\033[0m \033[37;40m|___|\033[0m \033[37;40m|___|\033[0m

0---- 1---- 2---- 3---- 4---- 5---- 6----
\033[31;47m K d \033[0m \033[31;47m 6 d \033[0m \033[30;47m K c \033[0m \033[30;47m 8 c \033[0m \033[30;47m 4 c \033[0m \033[30;47m A c \033[0m \033[31;47m Q h \033[0m

"""
    out = StringIO()
    game = Game(out=out, no_shuffle=True)
    slice_start = 0
    slice_end = min((slice_start + 9), len(new_board))

    game.deal()
    output = out.getvalue()
Exemple #12
0
def test_move_with_only_non_ace_throws_error():
	game = Game(no_shuffle=True)
	game.deal()

	with assert_raises(ValueError):
		game.move_card('6d')
Exemple #13
0
def test_move_card_throws_error_for_non_facing_up_card():
	game = Game(no_shuffle=True)
	game.deal()

	with assert_raises(ValueError):
		game.move_card('as')
Exemple #14
0
def test_won_false_for_non_winner():
	game = Game(no_shuffle=True)
	game.deal()

	assert_false(game.won())