Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control traceback length via assignment config #536

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please add new configurations at the bottom of the Keys (i.e. after runs_on)

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
14 changes: 12 additions & 2 deletions otter/test_files/ok_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,19 @@ def run_doctest(name, doctest_string, global_environment):
result = doctestrunner.summarize(verbose=True)
# An individual test can only pass or fail
if result.failed == 0:
return (True, '')
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, ''
Comment on lines +54 to +64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling Assignment() just creates an Assignment instance with the default values, so traceback_length will always be the default.



class OKTestFile(TestFile):
Expand Down
Loading