def test_count_sets_ve1(): """ Tests for the first kind of ValueError. - using fewer than 12 cards. """ with pytest.raises(ValueError) as excinfo: s.count_sets(["0000"]) assert excinfo.value.args[0] == "Please enter a list of exactly 12 unique cards, each with 4 digits, each of which being either 0, 1, or 2."
def test_count_sets_ve4(set_up_cards): cards_1, cards_2, cards_3 = set_up_cards with pytest.raises(ValueError) as excinfo: s.count_sets([ "5000", "0001", "0002", "0010", "0011", "0012", "0020", "0021", "0022", "0100", "0101", "0102" ]) assert excinfo.value.args[ 0] == "Please enter a list of exactly 12 unique cards, each with 4 digits, each of which being either 0, 1, or 2."
def test_count_sets_ve3(set_up_cards): """ Tests for the third kind of ValueError. - using strings that aren't four chars long. """ cards_1, cards_2, cards_3 = set_up_cards with pytest.raises(ValueError) as excinfo: s.count_sets(["000","001","002","000", "001","12","000","001", "022","000","0101","00"]) assert excinfo.value.args[0] == "Please enter a list of exactly 12 unique cards, each with 4 digits, each of which being either 0, 1, or 2."
def test_count_sets_ve2(set_up_cards): """ Tests for the second kind of ValueError. - using non-unique cards. """ cards_1, cards_2, cards_3 = set_up_cards with pytest.raises(ValueError) as excinfo: s.count_sets(["0000","0000","0002","0010", "0011","0012","0020","0021", "0022","0100","0101","0102"]) assert excinfo.value.args[0] == "Please enter a list of exactly 12 unique cards, each with 4 digits, each of which being either 0, 1, or 2."
def test_count_sets_counting(set_up_cards): cards_1, cards_2, cards_3 = set_up_cards sets_1 = 0 sets_2 = 0 sets_3 = 0 for i in combinations(cards_1, 3): if s.is_set(i[0], i[1], i[2]): sets_1 += 1 for i in combinations(cards_2, 3): if s.is_set(i[0], i[1], i[2]): sets_2 += 1 for i in combinations(cards_3, 3): if s.is_set(i[0], i[1], i[2]): sets_3 += 1 assert s.count_sets(cards_1) == sets_1, "failed at counting sets" assert s.count_sets(cards_2) == sets_2, "failed at counting sets" assert s.count_sets(cards_3) == sets_3, "failed at counting sets"
def test_count_sets_ve1(): with pytest.raises(ValueError) as excinfo: s.count_sets(["0000"]) assert excinfo.value.args[ 0] == "Please enter a list of exactly 12 unique cards, each with 4 digits, each of which being either 0, 1, or 2."