Esempio n. 1
0
 def run_test(tester_path, solution_path):
     solution = os.path.join(HELPERS_FOLDER, solution_path)
     tester = os.path.join(HELPERS_FOLDER, tester_path)
     return grader.test_module(
         tester_path = tester,
         solution_path = solution
     )["results"]
Esempio n. 2
0
    def run_tester(self,
                   tester_module,
                   solution_module,
                   working_dir=SOLUTION_FOLDER):
        grader.reset()
        results = grader.test_module(tester_module, solution_module,
                                     working_dir)

        for result in results["results"]:
            assert result["success"], dump_json(results)
Esempio n. 3
0
def run_test_suite(tester_file,
                   solution_file=None,
                   asset_files=[],
                   show_filename=False):
    if solution_file is None:
        if tester_file == "tester.py":
            solution_file = os.environ.get("VPL_SUBFILE0")
            assert solution_file, "$VPL_SUBFILE0 is not defined, env is " + str(
                os.environ)
        else:
            solution_file = tester_file.replace(TESTER_MARKER, "")

    points = 0
    max_points = 0
    file_missing = False

    if os.path.exists(solution_file):
        try:
            grader_result = grader.test_module(tester_file,
                                               solution_file,
                                               other_files=asset_files)
            print(grader_result)

            if not grader_result["results"]:
                print("Probleem testmimisel:", grader_result)

            for r in grader_result["results"]:
                # TODO: should it be r.get("grade", 1.0) ???
                max_points += grader_result.get("grade", 1.0)
                if r["success"]:
                    points += grader_result.get("grade", 1.0)

                print("<|--")
                print(
                    format_result(r, solution_file if show_filename else None))
                print("--|>")
                # make it easier to distinguish separate tests
                print()
                print()

        except Exception as e:
            # TODO: what about max points here?
            print("<|--")
            print("-Viga esitatud faili testimisel")
            traceback.print_exc()
            print("--|>")
    else:
        file_missing = True
        print("<|--")
        print("-Ei leidnud faili '" + solution_file + "'")
        print("--|>")

    return points, max_points, file_missing
Esempio n. 4
0
def run_test_suite(tester_file, solution_file=None, show_filename=False):
    if solution_file == None:
        if tester_file == "tester.py":
            solution_file = os.environ.get("VPL_SUBFILE0")
            assert solution_file, "$VPL_SUBFILE0 is not defined, env is " + str(os.environ)
        else:
            solution_file = tester_file.replace(TESTER_MARKER, "")

    points = 0
    max_points = 0
    file_missing = False
    
    if os.path.exists(solution_file):
        try:
            other_files = [f for f in os.listdir() if f != "vpl_execution" and not f.endswith(".sh") and not f.endswith(".py")]
            #print(other_files)
            grader_result = grader.test_module(tester_file, solution_file, other_files=other_files)
            print(grader_result)
            if not grader_result["results"]:
                print("Probleem testmimisel:", grader_result)
        
            for r in grader_result["results"]:
                # TODO: should it be r.get("grade", 1.0) ???
                max_points += grader_result.get("grade", 1.0)
                if r["success"]:
                    points += grader_result.get("grade", 1.0)
                    
                print("<|--")
                print(format_result(r, solution_file if show_filename else None))
                print("--|>")
                # make it easier to distinguish separate tests
                print()
                print()
            
        except Exception as e:
            # TODO: what about max points here?
            print("<|--")
            print("-Viga faili {} testimisel".format(solution_file))
            traceback.print_exc()
            print("--|>")
    else:
        file_missing = True
        print("<|--")
        print("-Ei leidnud faili '" + solution_file + "'")
        print("--|>")
        
    
    return points, max_points, file_missing
Esempio n. 5
0
 def setUpClass(cls):
     grader.reset()
     cls.results = grader.test_module(
         tester_path = cls.tester_path,
         solution_path = cls.solution_path
     )["results"]
 def setUpClass(cls):
     grader.reset()
     cls.results = grader.test_module(
         tester_path = os.path.join(CURRENT_FOLDER, "timing_tester.py"),
         solution_path = os.path.join(HELPERS_FOLDER, "_helper_timing_module.py")
     )["results"]
Esempio n. 7
0
 def setUpClass(cls):
     grader.reset()
     cls.results = grader.test_module(
         tester_path=os.path.join(CURRENT_FOLDER, "timing_tester.py"),
         solution_path=os.path.join(HELPERS_FOLDER,
                                    "_helper_timing_module.py"))["results"]
Esempio n. 8
0
 def run_test(tester_path, solution_path):
     solution = os.path.join(HELPERS_FOLDER, solution_path)
     tester = os.path.join(CURRENT_FOLDER, tester_path)
     return grader.test_module(tester_path=tester,
                               solution_path=solution)["results"]
Esempio n. 9
0
 def setUpClass(cls):
     #grader.reset()
     cls.results = grader.test_module(
         tester_path=cls.tester_path,
         solution_path=cls.solution_path)["results"]