This page contains API reference for various extensions of the grader module.
Module for testing fill-in-the-blanks task type.
Tester for the example task.
from grader import *
from grader.extensions import ast
template = """
number = int(input("Input a number: "))
if number > _____: # fill in the blank here...
print("Non-negative!")
else:
... # and here! Can be several lines
"""
ast.template_test(template)
Note that additional tests are also needed to verify the behaviour of the program.
Compares two AST trees with each other. Returns a list of differences, pairs of (expected, got).
In addition to doing straight-forward comparison, it allows for two kinds of wildcard expressions:
____ expressions which can be filled with a single expression/statement.
- ... expressions which can be filled with any number of
valid expressions/statements. Used in bodies.
Function matching a ____ expression. Used to allow to be filled with any expression.