Exemplo n.º 1
0
def test_is_valid_play(student):
    hands = game.deal()
    prev = random.choice(common.generate_plays(hands[0]))
    retval = []
    t_pass = True
    retval.append("prev = {0}".format(sorted(prev)))
    for play in common.generate_plays(hands[1]):
        x = check.compare_solutions(common.is_valid_play, student, t_args=[prev, play])
        t_pass = t_pass and x[0]
        retval.append(["play = {0}".format(sorted(play)), checkresult2list(x)])
    return t_pass, (retval)
Exemplo n.º 2
0
def test_is_valid_play(student):
    hands = game.deal()
    prev = random.choice(common.generate_plays(hands[0]))
    retval = []
    t_pass = True
    retval.append('prev = {0}'.format(sorted(prev)))
    for play in common.generate_plays(hands[1]):
        x = check.compare_solutions(common.is_valid_play,
                                    student,
                                    t_args=[prev, play])
        t_pass = t_pass and x[0]
        retval.append(['play = {0}'.format(sorted(play)), checkresult2list(x)])
    return t_pass, (retval)
Exemplo n.º 3
0
def test_generate_plays(student):
    hands = game.deal()
    retval = []
    t_pass = True
    for hand in hands:
        hand = list(hand)
        x = check.compare_solutions(common.generate_plays, student, t_args=[hand], transform=list2frozenset)
        t_pass = t_pass and x[0]
        retval.append("hand = {0}".format(hand))
        retval.append("sorted(hand) = {0}".format(sorted(hand)))
        # convert away from frozenset so that doesn't get displayed
        y = x[0], map(list, x[1]), map(list, x[2])
        retval.append(checkresult2list(y))
    return t_pass, (retval)
Exemplo n.º 4
0
def test_get_valid_plays(student):
    hands = game.deal()
    retval = []
    t_pass = True
    for prev in common.generate_plays(hands[0]):
        retval.append("prev = {0}".format(sorted(prev)))
        for hand in hands[1:]:
            x = check.compare_solutions(
                common.get_valid_plays,
                student,
                t_args=[prev, list(hand)],
                t_kwargs=dict(generate=common.generate_plays, is_valid=common.is_valid_play),
                transform=list2frozenset,
            )
            t_pass = t_pass and x[0]
            retval.append(["hand = {0}".format(sorted(hand)), checkresult2list(x)])
    return t_pass, (retval)
Exemplo n.º 5
0
def test_generate_plays(student):
    hands = game.deal()
    retval = []
    t_pass = True
    for hand in hands:
        hand = list(hand)
        x = check.compare_solutions(common.generate_plays,
                                    student,
                                    t_args=[hand],
                                    transform=list2frozenset)
        t_pass = t_pass and x[0]
        retval.append("hand = {0}".format(hand))
        retval.append("sorted(hand) = {0}".format(sorted(hand)))
        # convert away from frozenset so that doesn't get displayed
        y = x[0], map(list, x[1]), map(list, x[2])
        retval.append(checkresult2list(y))
    return t_pass, (retval)
Exemplo n.º 6
0
def test_get_valid_plays(student):
    hands = game.deal()
    retval = []
    t_pass = True
    for prev in common.generate_plays(hands[0]):
        retval.append('prev = {0}'.format(sorted(prev)))
        for hand in hands[1:]:
            x = check.compare_solutions(common.get_valid_plays,
                                        student,
                                        t_args=[prev, list(hand)],
                                        t_kwargs=dict(
                                            generate=common.generate_plays,
                                            is_valid=common.is_valid_play),
                                        transform=list2frozenset)
            t_pass = t_pass and x[0]
            retval.append(
                ['hand = {0}'.format(sorted(hand)),
                 checkresult2list(x)])
    return t_pass, (retval)