def test_can_find_every_card(): tab = Tableau() for row in range(len(tab.grid)): for col in range(len(tab.grid[row])): card = tab.card_at((row,col)) if card is not None: loc = tab.find_card(card) assert loc[0] == row and loc[1] == col
def test_can_find_every_card(): tab = Tableau() for row in range(len(tab.grid)): for col in range(len(tab.grid[row])): card = tab.card_at((row, col)) if card is not None: loc = tab.find_card(card) assert loc[0] == row and loc[1] == col
def test_moveables_are_moveable(): for i in range(1000): tab = Tableau() while not tab.has_moves(): tab = Tableau() moveables = tab.find_moveable() for m in moveables: card = tab.card_at(m) if card.rank == Ranks.TWO: left_gaps = [gap for gap in tab.find_gaps() if gap[1] == 0] assert len(left_gaps) > 0 else: target_card = Card(card.suit, Ranks.lower_rank(card.rank)) assert target_card is not None target_loc = tab.find_card(target_card) assert tab.card_at((target_loc[0], target_loc[1]+1)) is None
def test_moveables_are_moveable(): for i in range(1000): tab = Tableau() while not tab.has_moves(): tab = Tableau() moveables = tab.find_moveable() for m in moveables: card = tab.card_at(m) if card.rank == Ranks.TWO: left_gaps = [gap for gap in tab.find_gaps() if gap[1] == 0] assert len(left_gaps) > 0 else: target_card = Card(card.suit, Ranks.lower_rank(card.rank)) assert target_card is not None target_loc = tab.find_card(target_card) assert tab.card_at((target_loc[0], target_loc[1] + 1)) is None