Example #1
0
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")
Example #2
0
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.")
Example #3
0
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")
Example #4
0
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.")
Example #5
0
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")
Example #6
0
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)
Example #7
0
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")
Example #8
0
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')
Example #9
0
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")
Example #10
0
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")
Example #11
0
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)
Example #12
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)
Example #13
0
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")
Example #14
0
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)
Example #15
0
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")
Example #16
0
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)
Example #17
0
def input_exists():
    """input.c exists"""
    check50.exists("input.c")
    check50.include("input_soln")
Example #18
0
def compiles():
    """Credit.java compiles"""
    check50.include("Comp122.class")
    check50_java.compile("Credit.java")
Example #19
0
def exists():
    """climate.ipynb exists."""
    check50.include("../dist/climate/climate.txt")
    check50.exists("climate.ipynb")
Example #20
0
def exists():
    """placeholders.c exists"""
    check50.exists("string.c")
    check50.include("1.txt")
Example #21
0
def exists():
    """application.py exists"""
    check50.exists("application.py")
    check50.include("lookup.py")
    check50.py.append_code("helpers.py", "lookup.py")
Example #22
0
def shell_exists():
    """shell.c exists"""
    check50.exists("shell.c")
    check50.include("shell_soln")
Example #23
0
def exists():
    """hangman.py exists"""
    check50.exists("hangman.py")
    check50.include("dictionary.txt")
Example #24
0
def exists():
    """tideman.c exists"""
    check50.exists("tideman.c")
    check50.include("testing.c")
Example #25
0
def exists():
    """magic.c exists"""
    check50.exists("magic.c")
    check50.include("1.txt")
Example #26
0
def strings3_exists():
    """strings3.c exists"""
    check50.exists("strings3.c")
    check50.include("strings3_soln")
Example #27
0
def table_exists():
    """table.c exists"""
    check50.exists("table.c")
    check50.include("table_soln")
Example #28
0
def exists():
    """plurality.c exists"""
    check50.exists("plurality.c")
    check50.include("testing.c")
Example #29
0
def exists():
    """mario.c exists"""
    check50.exists("mario.c")
    check50.include("1.txt", "2.txt", "8.txt")
Example #30
0
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")