Skip to main content

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

Metadata

Release files for tcs-pythonwhat 2.24.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tcs-pythonwhat 2.24.21
File Size Uploaded
tcs_pythonwhat-2.24.21.tar.gz 151.1 kB Details

Release files / tcs_pythonwhat-2.24.21.tar.gz

Download URL tcs_pythonwhat-2.24.21.tar.gz
Size 151.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a2f6d3242a4e86f5a29fd53771475371f155cfc8ab80c22b50d519e46e7c9964
BLAKE2b-256 checksum
How to use checksums
f42b02e2b2d3fcff70d05219a18e138f0d9aa10ad7d5a07716aa0c4390a3d15f
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

2.24.21 This release

1 release file

2.24.9

2 release files

2.24.8

2 release files

2.24.7

2 release files

2.24.6

2 release files

2.24.5

2 release files

2.24.4

2 release files

2.24.3

2 release files

2.24.2

2 release files

2.24.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page