diff --git a/otter/assign/assignment.py b/otter/assign/assignment.py index 18363624..b1e1ccf3 100644 --- a/otter/assign/assignment.py +++ b/otter/assign/assignment.py @@ -19,6 +19,13 @@ class Assignment(fica.Config, Loggable): Configurations for the assignment. """ + + traceback_length: Optional[str] = fica.Key( + description="how much of the traceback message to print upon test failure", + default="assertion_msg", + validator=fica.validators.choice(["full", "assertion_msg", "none"]) + ) + name: Optional[str] = fica.Key( description="a name for the assignment (to validate that students submit to the correct " \ "autograder)", diff --git a/otter/test_files/ok_test.py b/otter/test_files/ok_test.py index 5ce5853a..c999b33a 100644 --- a/otter/test_files/ok_test.py +++ b/otter/test_files/ok_test.py @@ -51,7 +51,17 @@ def run_doctest(name, doctest_string, global_environment): if result.failed == 0: return (True, '') else: - return False, runresults.getvalue() + from ..assign.assignment import Assignment + if Assignment().traceback_length == 'full': + return False, runresults.getvalue() + elif Assignment().traceback_length == 'assertion_msg': + err_msg = runresults.getvalue() + if 'AssertionError: ' in err_msg: + return False, err_msg[err_msg.index('AssertionError: '):] + else: + return False, '' + elif Assignment().traceback_length == 'none': + return False, '' class OKTestFile(TestFile):