Skip to main content

A collection of parameterizable tests for automatic grading.

Project description

Generic Grader

A collection of generic tests for grading programming assignments.

This project is still in very early development. Expect breaking changes.

Installation

pip install generic-grader

Usage

  1. Name the reference solution reference.py, and place it in a tests subdirectory of the directory containing the student's code.

  2. Add a configuration file for the assignment in the tests subdirectory (e.g. tests/config.py). It might look something like this:

    from parameterized import param
    from generic_grader.style import comments # Import the tests you want to use
    from generic_grader.utils.options import Options
    
    # Create tests by calling each test type's build method.
    # They should all start with the word `test_` to be discovered by unittest.
    # Adding a number after `test_` can be used to control the run order.
    # The argument is a list of `param` objects, each with an `Options` object.
    # See the Options class for more information on the available options.
    test_01_TestCommentLength = comments.build(
       [
          param(
              Options(
                  sub_module="hello_user",
                  hint="Check the volume of comments in your code.",
                  entries=("Tim the Enchanter",),
              ),
          ),
          param(
              Options(
                  sub_module="hello_user",
                  hint="Check the volume of comments in your code.",
                  entries=("King Arthur",),
              ),
          ),
       ]
    )
    
  3. Run the tests.

    python -m unittest tests/config.py
    

Contributing

  1. Clone the repo onto your machine.

    • HTTPS

      git clone https://github.com/Purdue-EBEC/generic-grader.git
      
    • SSH

      git clone git@github.com:Purdue-EBEC/generic-grader.git
      
  2. Set up a new virtual environment in the cloned repo.

    cd generic-grader
    python3.12 -m venv .env3.12
    
  3. Activate the virtual environment. If you are using VS Code, there may be a pop-up to do this automatically when working from this directory.

    • Linux/macOS

      source .env3.12/bin/activate
      
    • Windows

      .env3.12\Scripts\activate
      
  4. Install tesseract-ocr

  5. Install ghostscript

  6. Install the package. Note that this installs the package as editable, so edits will be automatically reflected in the installed package.

    pip install -e .[dev]
    

    or

    uv sync --extra dev
    
  7. Install the pre-commit hooks.

    pre-commit install
    
  8. Run the tests.

    pytest
    
  9. Make changes ...

  10. Deactivate the virtual environment.

deactivate

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

generic_grader-0.2.6.tar.gz (149.1 kB view details)

Uploaded Source

Built Distribution

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

generic_grader-0.2.6-py3-none-any.whl (72.2 kB view details)

Uploaded Python 3

File details

Details for the file generic_grader-0.2.6.tar.gz.

File metadata

  • Download URL: generic_grader-0.2.6.tar.gz
  • Upload date:
  • Size: 149.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for generic_grader-0.2.6.tar.gz
Algorithm Hash digest
SHA256 7e4e9228878f4597805b04504ac5c5d86786bec90a42ad49b3363df4ed54d030
MD5 1ce731185d17f0a16eaca77f1116fba3
BLAKE2b-256 3ce2ac1af46f13bb47fb436d171bee4e6089cf2030142c2c0803f1655744addd

See more details on using hashes here.

File details

Details for the file generic_grader-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: generic_grader-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 72.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for generic_grader-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5aa4a335b90bde2a1b161db28ee1bbf833a82ab805d8fa66e5389fa9bdcafe40
MD5 96bf09ec08a783b81998621e86d262bf
BLAKE2b-256 15857a737c8d048c8ea7cf48d03f78e703ced8b2075c623ebd5c8ed0dbfd3237

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