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.9.6
pip3.9 install -r requirements.txt
pip3.9 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

tcs_pythonwhat-2.24.21.tar.gz (151.1 kB view details)

Uploaded Source

File details

Details for the file tcs_pythonwhat-2.24.21.tar.gz.

File metadata

  • Download URL: tcs_pythonwhat-2.24.21.tar.gz
  • Upload date:
  • Size: 151.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.5 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.0.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for tcs_pythonwhat-2.24.21.tar.gz
Algorithm Hash digest
SHA256 a2f6d3242a4e86f5a29fd53771475371f155cfc8ab80c22b50d519e46e7c9964
MD5 962858dc769135178d05e03d283f0462
BLAKE2b-256 f42b02e2b2d3fcff70d05219a18e138f0d9aa10ad7d5a07716aa0c4390a3d15f

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