Skip to main content

An package for easy autograding.

Project description

Grade: Get Readymade Autograding Done Efficiently

A utility for programming assignment autograding.


Grade attempts alleviate typical problems in autograding workflows. By providing easy-to-use wrappers to work directly with executable files, Grade can test almost anything. Combining that with the ScoringMixin and the GradedRunner, allows you to output your scores for Gradescope or an in-house Markdown report.

Documentation Status




python -m pip install grade


FROM thoward27/grade:latest


  1. Create a unittest.TestCase
  2. Optionally, add in the grade.mixins.ScoringMixin
  3. For each question, you can use @grade.decorators.weight(x) or self.weight = x to set the weight of a question.
  4. If you wish to assign partial credit for some portion of a test, you can use self.score = x. (Warning: if you leave a test with partial credit, the student will receive that score, to give full credit at the end simply run self.score = self.weight)
  5. Run the tests using grade.runners.GradedRunner().run(TestSuite), which returns a Result object.
  6. Once you have the results, you can output them to json via the property results.json


To properly output scores for Gradescope, simply write the json results to /autograder/results/results.json

Option 1: Redirection

Given the following python snippet at the end of your test file:

import unittest
from grade.runners import GradedRunner
if __name__ == "__main__":
    suite = unittest.TestLoader().discover('./', pattern='test*')

Simply redirect the output:

python > autograder/results/results.json

Option 2: Direct Writing

Of course, you can also write directly to the file in your code.

Ensure you only do this in one place, or it may overwrite your work!

import unittest
from grade.runners import GradedRunner

if __name__ == "__main__":
    suite = unittest.TestLoader().discover('./', pattern='test*')
    results = GradedRunner().run(suite)
    with open('/autograder/results/results.json', 'w') as f:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for grade, version 0.8.0
Filename, size File type Python version Upload date Hashes
Filename, size grade-0.8.0-py3-none-any.whl (21.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size grade-0.8.0.tar.gz (11.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page