diff --git a/unitgrade/__pycache__/__init__.cpython-36.pyc b/unitgrade/__pycache__/__init__.cpython-36.pyc index 845822da1bc18d27e8c2481f064c69b63907c5ec..41c8cae17ecac0b36d54439732f20e778a3e90b0 100644 Binary files a/unitgrade/__pycache__/__init__.cpython-36.pyc and b/unitgrade/__pycache__/__init__.cpython-36.pyc differ diff --git a/unitgrade/__pycache__/unitgrade.cpython-36.pyc b/unitgrade/__pycache__/unitgrade.cpython-36.pyc index 650192ef2a15d66101d9b6ed2d8900ed8fe6506d..4fdacefd982002048b628fb9e4ce082fe99b01ed 100644 Binary files a/unitgrade/__pycache__/unitgrade.cpython-36.pyc and b/unitgrade/__pycache__/unitgrade.cpython-36.pyc differ diff --git a/unitgrade/__pycache__/unitgrade_helpers.cpython-36.pyc b/unitgrade/__pycache__/unitgrade_helpers.cpython-36.pyc index b1ef9dc6b9b3154d2cebad1295e20b940d1909eb..4ec59209cb632db45b779350e883f1da9136585c 100644 Binary files a/unitgrade/__pycache__/unitgrade_helpers.cpython-36.pyc and b/unitgrade/__pycache__/unitgrade_helpers.cpython-36.pyc differ diff --git a/unitgrade/unitgrade.py b/unitgrade/unitgrade.py index 8b6496e26c1311b62990f0c1fa9a791417f4dfdb..e9fd63afd872f2a7d0bdb885da69e004dba62cf1 100644 --- a/unitgrade/unitgrade.py +++ b/unitgrade/unitgrade.py @@ -69,11 +69,16 @@ class Capturing(list): class QItem(unittest.TestCase): title = None - testfun = unittest.TestCase.assertEqual + testfun = None tol = 0 _computed_answer = None # Internal helper to later get results. def __init__(self, working_directory=None, correct_answer_payload=None, *args, **kwargs): + if self.tol > 0 and self.testfun is None: + self.testfun = self.assertL2Relative + else: + self.testfun = unittest.TestCase.assertEqual + self.name = self.__class__.__name__ self._correct_answer_payload = correct_answer_payload super().__init__(*args, **kwargs) diff --git a/unitgrade/unitgrade_helpers.py b/unitgrade/unitgrade_helpers.py index 4db4c2b7695559a25b7b48d20ed888ba4e4e57d7..3af947ab433a72e02e56cad88043d7e449c34fbc 100644 --- a/unitgrade/unitgrade_helpers.py +++ b/unitgrade/unitgrade_helpers.py @@ -46,7 +46,7 @@ parser.add_argument('--passall', action="store_true", help='Automatically pass # const=sum, default=max, # help='sum the integers (default: find the max)') -def evaluate_report_student(report, question=None, qitem=None, unmute=None, passall=None): +def evaluate_report_student(report, question=None, qitem=None, unmute=None, passall=None, ignore_missing_file=False): args = parser.parse_args() if question is None and args.q is not None: question = args.q @@ -54,7 +54,8 @@ def evaluate_report_student(report, question=None, qitem=None, unmute=None, pass question, qitem = [int(v) for v in question.split(".")] else: question = int(question) - if not os.path.isfile(report.computed_answers_file): + + if not os.path.isfile(report.computed_answers_file) and not ignore_missing_file: raise Exception("> Error: The pre-computed answer file", os.path.abspath(report.computed_answers_file), "does not exist. Check your package installation") if unmute is None: