Skip to main content

Submission correctness tests for Python

Project description


Build Status PyPI version Documentation Status FOSSA Status

Verify Python code submissions and auto-generate meaningful feedback messages. Originally developed for Python exercises on DataCamp for so-called Submission Correctness Tests, but can also be used independently.


# latest stable version from PyPi
pip install pythonwhat

# latest development version from GitHub
pip install git+


To experiment locally, you can use setup_state() and write SCTs interactively. The code throws an error when the underlying checks fail.

# make all checking functions available
from pythonwhat.test_exercise import prep_context
_, ctxt = prep_context()

# initialize state with student and solution submission
from pythonwhat.test_exercise import setup_state
setup_state(stu_code = "x = 5", sol_code = "x = 4")

# No error: x is defined in both student and solution process

# TestFail: Did you correctly define the variable `x`? Expected `4`, but got `5`.

# Debugging state
Ex()._state               # access state object
dir(Ex()._state)          # list all elements available in the state object
Ex()._state.student_code  # access student_code of state object

To learn how to include an SCT in a DataCamp course, visit

Run tests

pyenv local 3.9.6
pip3.9 install -r requirements.txt
pip3.9 install -e .


Bugs? Questions? Suggestions? Create an issue, or contact us!


FOSSA Status

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

pythonwhat-2.24.4.tar.gz (75.4 kB view hashes)

Uploaded Source

Built Distribution

pythonwhat-2.24.4-py3-none-any.whl (85.1 kB view hashes)

Uploaded Python 3

Supported by

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