def exists(): """Checking if all files exist.""" check50.include("data") check50.exists("adventure.py") check50.exists("room.py") check50.exists("inventory.py") check50.exists("item.py")
def analyzeExists(): """Checking if analyze.sh file exists and contains the sha-bang line""" check50.exists("analyze.sh") check50.include("sample.txt") output = check50.run("xxd -p -l 1 analyze.sh").stdout() if output != "23\n": raise check50.Failure("It looks your script does not contain the sha-bang line or the sha-bang line contains a typo.")
def exists(): """caesar.cpp exists.""" check50.exists("caesar.cpp") check50.include("input.txt") check50.include("expected_output1.txt", "expected_output2.txt", "expected_output3.txt", "expected_output4.txt", "expected_output5.txt", "expected_output6.txt")
def menuExists(): """Checking if menu.sh file exists and contains the sha-bang line""" check50.exists("menu.sh") check50.include("menu.sh.x") output = check50.run("xxd -p -l 1 menu.sh").stdout() if output != "23\n": raise check50.Failure("It looks your script does not contain the sha-bang line or the sha-bang line contains a typo.")
def exists(): """queue.h, queue.c, queue_example.c, and Makefile exist""" check50.exists("queue.h") check50.exists("queue.c") check50.exists("queue_example.c") check50.exists("Makefile") check50.include("queue_example_soln")
def exists(): """Notebook exists""" check50.include("check_jupyter.py", "data/", "answers.py") # Grab the last test test_ids = get_test_ids(NOTEBOOK_PATH) last_test_id = test_ids[-1] # Grab all cells up to the last test cell check_jupyter = check50.internal.import_file("check_jupyter", "check_jupyter.py") cells = check_jupyter.cells_up_to(NOTEBOOK_PATH, last_test_id) # Gather all results results = [] with check_jupyter.executor() as execute: for cell in cells: # Execute the cell try: execute(cell) exception = "" passed = True except check50.Failure as f: exception = str(f) passed = False # If it's a test cell, record result if check_jupyter.is_test_cell(cell): results.append( (check_jupyter.get_cell_id(cell), passed, exception)) # Pass down the results to the actual checks return tuple(results)
def exists(): """substitution.cpp exists""" check50.exists("substitution.cpp") check50.include("input.txt") check50.include("expected_output1.txt", "expected_output2.txt", "expected_output3.txt", "expected_output4.txt", "expected_output5.txt", "expected_output6.txt", "expected_output7.txt", "expected_output8.txt")
def checkstyle_javadoc_methods(): """methods `swap` and `main` documented?""" stylefile = "styles/javadoc-method.xml" check50.include("styles") check50_checkstyle.run_and_interpret_checkstyle( checks_file=stylefile, rationale="{report}", target='StringTools.java')
def exists(): """Checking if all files exist.""" check50.include("data") # check50.include("data/CrowtherRooms.txt") # check50.include("data/CrowtherItems.txt") check50.exists("adventure.py") check50.exists("room.py") check50.exists("inventory.py") check50.exists("item.py")
def exists(): """readability.cpp exists""" check50.exists("readability.cpp") check50.include("input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt", "input6.txt", "input7.txt", "input8.txt", "input9.txt", "input10.txt") check50.include("expected_output1.txt", "expected_output2.txt", "expected_output3.txt", "expected_output4.txt", "expected_output5.txt", "expected_output6.txt", "expected_output7.txt", "expected_output8.txt", "expected_output9.txt", "expected_output10.txt")
def apostrophe(): """handles words with apostrophes properly""" check50.include("apostrophe") check50.run( "./speller apostrophe/without/dict apostrophe/with/text").stdout( open("apostrophe/outs/without-with")).exit(0) check50.run( "./speller apostrophe/with/dict apostrophe/without/text").stdout( open("apostrophe/outs/with-without")).exit(0) check50.run("./speller apostrophe/with/dict apostrophe/with/text").stdout( open("apostrophe/outs/with-with")).exit(0)
def outliers(stdout): """print de outliers voor ieder jaar""" check50.include("answers/outliers.csv") with open("outliers.csv") as f: answers = list(csv.DictReader(f)) for a in answers: text_int = "{} is de waarde op {}/{}/{} een outlier".format(*a.values()) a["temp"] = int(a["temp"]) / 10 text_float = "{} is de waarde op {}/{}/{} een outlier".format(*a.values()) find_any_prints([text_float, text_int], stdout)
def exists(): """sudoku.ipynb exists.""" for directory in ("../data/easy", "../data/hard"): check50.include(directory) # Also copy all data files to check dir # Just in case the student's solution happens to rely on this local_dir = os.path.basename(directory) for local_file in os.listdir(local_dir): shutil.copyfile(os.path.join(local_dir, local_file), os.path.basename(local_file)) check50.exists("sudoku.ipynb")
def variation_yearly(stdout): """print een overzicht per jaar van het maximum en minimum voor dat jaar""" check50.include("answers/variation_yearly.csv") with open("variation_yearly.csv") as f: answers = list(csv.DictReader(f)) for a in answers: text_int = "{} varieerde de temperatuur tussen {} graden op {}/{} en {} graden op {}/{}".format(*a.values()) a["min_temp"] = int(a["min_temp"]) / 10 a["max_temp"] = int(a["max_temp"]) / 10 text_float = "{} varieerde de temperatuur tussen {} graden op {}/{} en {} graden op {}/{}".format(*a.values()) find_any_prints([text_float, text_int], stdout)
def exists(): """resize.c and bmp.h exist.""" check50.include("bmp.h") check50.include("small.bmp", "smiley.bmp", "large.bmp") check50.include("small2.bmp", "small3.bmp", "small4.bmp", "small5.bmp") check50.include("large2.bmp", "smiley2.bmp", "smiley3.bmp") check50.exists("resize.c")
def longest_heatwave(stdout): """print een overzicht per jaar van de lengte van de langste hittegolf""" zero_days = "duurde de langste hittegolf 0 dagen" if zero_days in stdout: raise check50.Failure( f'vond het volgende in de output: "{zero_days}"', help="print geen jaartallen uit waarin er geen hittegolf heeft plaatsgevonden" ) check50.include("answers/longest_heatwave.csv") with open("longest_heatwave.csv") as f: answers = list(csv.DictReader(f)) for a in answers: text = "{} duurde de langste hittegolf {} dagen".format(*a.values()) find_any_prints([text], stdout)
def input_exists(): """input.c exists""" check50.exists("input.c") check50.include("input_soln")
def compiles(): """Credit.java compiles""" check50.include("Comp122.class") check50_java.compile("Credit.java")
def exists(): """climate.ipynb exists.""" check50.include("../dist/climate/climate.txt") check50.exists("climate.ipynb")
def exists(): """placeholders.c exists""" check50.exists("string.c") check50.include("1.txt")
def exists(): """application.py exists""" check50.exists("application.py") check50.include("lookup.py") check50.py.append_code("helpers.py", "lookup.py")
def shell_exists(): """shell.c exists""" check50.exists("shell.c") check50.include("shell_soln")
def exists(): """hangman.py exists""" check50.exists("hangman.py") check50.include("dictionary.txt")
def exists(): """tideman.c exists""" check50.exists("tideman.c") check50.include("testing.c")
def exists(): """magic.c exists""" check50.exists("magic.c") check50.include("1.txt")
def strings3_exists(): """strings3.c exists""" check50.exists("strings3.c") check50.include("strings3_soln")
def table_exists(): """table.c exists""" check50.exists("table.c") check50.include("table_soln")
def exists(): """plurality.c exists""" check50.exists("plurality.c") check50.include("testing.c")
def exists(): """mario.c exists""" check50.exists("mario.c") check50.include("1.txt", "2.txt", "8.txt")
def helpers_exists(): """helpers.c exists""" check50.exists("helpers.c") check50.include("helpers.h", "wav.h", "wav.c", "is_rest.c", "duration.c", "frequency.c")