Skip to content

Commit

Permalink
Control traceback length via assignment config
Browse files Browse the repository at this point in the history
  • Loading branch information
joelostblom committed Sep 28, 2023
1 parent e31415b commit cb8a86a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions otter/assign/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
12 changes: 11 additions & 1 deletion otter/test_files/ok_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit cb8a86a

Please sign in to comment.