def test_new_tableau_has_moveables(): for i in range(1000): tab = Tableau() while not tab.has_moves(): tab = Tableau() moveables = tab.find_moveable() assert len(moveables) > 0
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
def test_has_moves_returns_true_for_new_tableau(): t = Tableau() assert t.has_moves()