Skip to main content

Pytest extension for scoring programming assignments.

Project description

pytest-grader

A pytest plugin for testing and scoring programming assignments.

Features

  • Assignment Scoring
    • Add point values to test functions using the @points(n) decorator
    • Show a score summary when running pytest --score
  • Test Locking as described in Basu et al., Automated Problem Clarification at Scale (abstract, pdf)
    • Lock doctests using the # LOCK comment before the function.
    • pytest-grader lock [src] [dst] will generate a copy of src with doctests locked.
    • pytest --unlock provides an interactive interface for unlocking locked doctests.
  • Test Isolation
    • Modules listed under reload_modules in grader.yaml are reloaded before each test, so a test that mutates a module (e.g. by monkeypatching one of its functions) does not affect later tests.
    • Globals injected by pytest's assertion rewriting (@py_builtins, @pytest_ar) are removed from doctest namespaces.
  • Progress Logging
    • Snapshots of assignment files, test case results, and unlocking attempts are stored in a grader.sqlite.
    • This file is designed to be submitted along with the assignment as a record of how the assignment was completed.

Usage

Include a conftest.py file in the distribution of your assignment that contains pytest_plugins = ["pytest_grader"].

Describe the assignment in a grader.yaml file next to it:

included_files:   # Files snapshotted into grader.sqlite when tests run
  - hog.py
reload_modules:   # Modules reloaded before each test for isolation
  - hog

See the examples directory for more usage info.

License

MIT

Updating versions

  • Change version in pyproject.toml
  • uv build
  • uv publish

Project details


Download files

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

Source Distribution

pytest_grader-0.1.5.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_grader-0.1.5-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest_grader-0.1.5.tar.gz.

File metadata

  • Download URL: pytest_grader-0.1.5.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for pytest_grader-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a6d7bb86177e581869da18f1e01bf05fc13241c09bc754e65663256fe41f0cc8
MD5 3490fd9e777eab34f70bcce1e967dcf6
BLAKE2b-256 fdc83c89178fd5bbf5546c9ea980c87a18175ea0bbc50348069f3c016e757f20

See more details on using hashes here.

File details

Details for the file pytest_grader-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_grader-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 69e39007b709b759b579118e612def2f01cd3a5f6c5203ce62946270a40050d6
MD5 bd9b163621fac62e31bc4b5c439712c0
BLAKE2b-256 3df6d38ec75d4a2bf41d2efa840e88adbd33c3f7a990417ea35918de47b5cc62

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page