def check_email(test_email, grade_email): if grade_email in found_emails: found_emails.remove(grade_email) correct_emails.remove(grade_email) student("Test:", test_email, "PASSED") return "PASSED" else: student("Test:", test_email, "FAILED!") grader("Test:", test_email, "FAILED!") return "FAILED"
newio = timeout.CustomIO() oio = sys.stdout, sys.stdin try: sys.stdout, sys.stdin = newio, newio try: runpy.run_module('rumple') except: pass ans = newio.printed[0] name = ' '.join(ans.strip().split('\n')[0].split()[7:-3]) finally: sys.stdout, sys.stdin = oio if name is None: student('We failed to find the answer on the first line of output') grader('Score: 0 / 10') quit() if expect("rumple", [name], [re.compile(r".* $"), re.compile(r".*")], "Failed first example."): correct += 1 else: wrong += 1 if expect("rumple", ['x' + name, name], [re.compile(r".* $"), re.compile(r".* $"), re.compile(r".*")], ""): correct += 1 else: wrong += 1
"Failed multi-line punctuation test.", maxtime=5): correct += 1 else: wrong += 1 if expect( "spellcheck", ["Ne'er 'ave I bein' so hurt.", ''], [None, re.compile('^\s*MISSPELLED: *ave\s*MISSPELLED: *bein\s*$'), ''], "Failed apostrophe test.", maxtime=5): correct += 1 else: wrong += 1 if expect("spellcheck", ["yes", 'yess', 'yes'] * 4 + [''], [None] + ['', re.compile('^\s*MISSPELLED: *yess\s*$'), ''] * 4 + [''], "Failed many-line test test.", maxtime=5): correct += 1 else: wrong += 1 if wrong == 0: student("Congratulations, you passed all of our tests!") else: student("You passed", correct, "out of", correct + wrong, "tests.") grader("Score:", correct, "/", correct + wrong)
else: student(func, 'was supposed to invoke mean once') except: student( "something unexpected happened in our autograding; your score below might be incorrectly small" ) student(func + ' passed', fcor, 'out of', 6, 'automated test cases') correct += fcor fcor = 0 func = 'middle_average' try: fcor += test_func(mod, func, 8 / 3, None, [1, 1, 6], full=True) fcor += test_func(mod, func, 4.932882862316247, None, [1, 6, 6]) fcor += test_func(mod, func, .1, None, [.1, -.6, .6]) if func in funcs and funcs[func][1].count('mean') == 1: fcor += 1 else: student(func, 'was supposed to invoke mean once') if func in funcs and funcs[func][1].count('rms') == 1: fcor += 1 else: student(func, 'was supposed to invoke rms once') if func in funcs and funcs[func][1].count('median') == 2: fcor += 1 else: student(func, 'was supposed to invoke median twice') except: student( "something unexpected happened in our autograding; your score below might be incorrectly small" ) student(func + ' passed', fcor, 'out of', 8, 'automated test cases') correct += fcor grader('Score:', correct, '/', 28)
from gradetools import grader, student, test_func correct = 0 mod = 'credit_card' func = 'check' try: correct += test_func(mod, func, False, None, [1], full=True) for num in [5490123456789129, 5490123456789122, 54906789122]: correct += test_func(mod, func, False, None, [num]) for num in [378282246310005, 6011111111111117, 5555555555554444]: correct += test_func(mod, func, True, None, [num]) except: student("something unexpected happened in our autograding; your score below might be incorrectly small") student(func+' passed', correct, 'out of', 9, 'automated test cases') grader('Score:', correct, '/', 9)
if grade_email in found_emails: found_emails.remove(grade_email) student("Bonus:", test_email, "PASSED (+1 bonus!)") return "PASSED" else: student("Bonus:", test_email, "fail (does not count against you)") return "FAILED" try: import email_finder except: student( "You are missing at least one function or a function's header is incorrect. Tests will not run until you fix this problem." ) grader("Exception thrown - missing function") bad_function = True exit() program_search = open("email_finder.py", "r") for line in program_search: if "print(" in line: student( "You are calling print from inside your code. Please remove all testing statements before submitting." ) bad_function = False exit() if not bad_function: try:
'rank': 3807, 'pay': 60770.0 }, None, ['Ali Reza Forghani Esfahani']) correct += test_func( mod, func, { 'title': 'Laboratory & Research Spec II', 'breakdown': { 'Base salary': 58496.0 }, 'rank': 3978, 'pay': 58496.0 }, None, ['pamela-neff']) correct += test_func(mod, func, {}, None, ['thomas-jefferson']) correct += test_func( mod, func, { 'rank': 2992, 'pay': 75000.0, 'breakdown': { 'Base salary': 75000.0 }, 'title': 'Lecturer' }, None, ['luther-tychonievich']) correct += test_func(mod, func, {}, None, ['upsorn-praphamontripong']) except: student( "something unexpected happened in our autograding; your score below might be incorrectly small" ) student(func + ' passed', correct, 'out of', 12, 'automated test cases') grader('Score:', correct, '/', 12)
mod, func, [[ 'GREE', '1020', '100', 'Elementary Greek', 'John Dillery', 'Lecture', '4', 'true', 'false', 'true', 'false', 'true', '1000', '1050', 'New Cabell Hall 066', '11', '15' ], [ 'GREE', '1020', '101', 'Elementary Greek', 'Rebecca Frank', 'Discussion', '0', 'false', 'true', 'false', 'true', 'false', '930', '1045', 'New Cabell Hall 066', '6', '15' ], [ 'GREE', '2020', '001', 'Intermediate Greek II', 'Jon Mikalson', 'Lecture', '3', 'true', 'false', 'true', 'false', 'true', '1000', '1050', 'Cocke Hall 115', '14', '20' ], [ 'GREE', '3020', '001', 'Advanced Reading in Greek', 'Ivana Petrovic', 'Lecture', '3', 'false', 'true', 'false', 'true', 'false', '1100', '1215', 'Office', '3', '9' ]], None, ['GREE', False, None, None, 1100]) except: student( "something unexpected happened in our autograding; your score below might be incorrectly small" ) student(func + ' passed', correct, 'out of', 7, 'automated test cases') correct += oc grader('Score:', correct, '/', 6 + 7)