otter-grader icon indicating copy to clipboard operation
otter-grader copied to clipboard

Auto-ignore lines calling the exception test function in Otter Assign

Open chrispyles opened this issue 2 years ago • 1 comments

For exception tests in Otter Assign, test cells are formatted like

def test(var):
    # some logic

test(var) # IGNORE

Needing to remember the # IGNORE comment is cumbersome. Since each cell should have only 1 test in it, we can parse the cell and remove all lines outside the function body.

chrispyles avatar Aug 24 '22 04:08 chrispyles

This can probably be done by parsing the cell's source as an AST, removing all nodes except the first def node, and using astunparse to convert this back to Python code.

chrispyles avatar Dec 28 '23 05:12 chrispyles