Skip to main content

Submission correctness tests for Python

Project description

pythonwhat

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.

Installation

# latest stable version from PyPi
pip install pythonwhat

# latest development version from GitHub
pip install git+https://github.com/datacamp/pythonwhat

Demo

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()
globals().update(ctxt)

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

Ex().check_object('x')
# No error: x is defined in both student and solution process

Ex().check_object('x').has_equal_value()
# 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 https://instructor-support.datacamp.com.

Run tests

pyenv local 3.12.7
pip3.12 install -r requirements-test.txt
pip3.12 install -e .
pytest

Contributing

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

License

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.30.1.tar.gz (106.3 kB view details)

Uploaded Source

Built Distribution

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

pythonwhat-2.30.1-py3-none-any.whl (85.6 kB view details)

Uploaded Python 3

File details

Details for the file pythonwhat-2.30.1.tar.gz.

File metadata

  • Download URL: pythonwhat-2.30.1.tar.gz
  • Upload date:
  • Size: 106.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for pythonwhat-2.30.1.tar.gz
Algorithm Hash digest
SHA256 802c20d0057f077bbc295140c1ed0045909487578831d2eea0a756ba14b02d80
MD5 0ca138fea1bfa29cf3cc48c9b00fd702
BLAKE2b-256 ce089b0527c336e532963d9f97d41598ee00dad7e94414850f373c6805c6b98e

See more details on using hashes here.

File details

Details for the file pythonwhat-2.30.1-py3-none-any.whl.

File metadata

  • Download URL: pythonwhat-2.30.1-py3-none-any.whl
  • Upload date:
  • Size: 85.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for pythonwhat-2.30.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e141aaed630898009ae351ca80ea2f79fe159ec5dec6ec8cf8766005a1ef234
MD5 23d8488dc30195fc0baca1ab895dc90c
BLAKE2b-256 440844eddff11fcd9430f6c238af32f11df0ccf09e02a4789cc77815c4228aab

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