Reference¶
- class csgrader.CsharpGrader(with_timings: bool = False)¶
Main class of the module
This class should be subclassed by an application.
- build_simple(name: str, submitter_files: Iterable[str] | str, given_files: Iterable[str] | None)¶
Build a program
Builds a program from the submitter_files plus given_files.
- Parameters:
name – a name used in reporting
submitter_files – the name of the file(s) submitted by the student
given_files – the name of the files given by the instructor.
- build_xunit(name: str, submitter_files: Iterable[str] | str, given_files: Iterable[str] | None)¶
Build a program based on xUnit and Shouldly
Builds a dll from the submitter_files and a test program from the given_files where the latter uses the dll.
- Parameters:
name – a name used in reporting
submitter_files – the name of the file(s) submitted by the student
given_files – the name of the files given by the instructor.
- start() None ¶
Method to be called after defining a subclass of this class
- tests() None ¶
Method that the user should override in a subclass
Code to build and run programs should be called inside this function.
- class csgrader.Equality(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Class with values that indicate how strict equality is enforced
- LOOSE¶
Combination of extra space and empty lines
- STRICT¶
Files should be exactly the same
- WITH_EMPTY_LINES¶
Extra empty lines are permitted
- WITH_EXTRA_SPACE¶
One or more white space characters count as one space
- class csgrader.Program(name, output, prog, result)¶
Class representing a program built with build_simple
Derived from
ProgramBase
.- run_and_check(name: str, args: Iterable[str] | str, expected_output: str, /, points: float = 1, cmp: Equality = Equality.STRICT, expected_status: int | None = 0, fail_msg: str | None = None)¶
Run a program built earlier and check the output
The standard output written by the program is compared to the contents of a file. The results of this run are reported by Prairielearn.
- Parameters:
name (str) – A name used by Prairielearn for reporting
args ([str]) – The command line arguments that are provided to the program.
expected_output (str) – The file name, relative to directory tests/expected, that contains the expected content of the output.
points (float) – (keyword argument) The number of points awarded when this run succeeds (default: 1).
cmp (Equality) – (keyword argument) Influences how strict the comparison with the expected output is.
expected_status (int) – (keyword argument) The program status that indicates a succesful run (default: 0). If the value is None, the program status is not taken into account. Otherwise, the status must be this value, before proceeding to comparison of the content at all.
fail_msg – A message that is reported if the run fails. (default: None, keyword argument)
- class csgrader.ProgramBase(name, output, prog, result)¶
Base class used for programs built with build_simple and build_xunit
- run_with_status(name: str, args: Iterable[str] | str = [], /, points: float = 1, expected_status: int = 0, fail_msg: str | None = None)¶
Run a program built earlier and check the output status
The results of this run are reported by Prairielearn.
- Parameters:
name (str) – A name used by Prairielearn for reporting
args ([str]) – The command line arguments that are provided.
points (float) – The number of points awarded when this run succeeds. This is a keyword argument with default value 1.
expected_status – The program status that indicates a succesful run (default: 0, keyword argument)
fail_msg – A message that is reported if the run fails. (default: None, keyword argument)
- class csgrader.XunitTest(name, output, prog, result)¶
Class representing a program built with build_xunit
Derived from
ProgramBase
. Does not have extra functionality with respect to the base class.