项目作者: datacamp

项目描述 :
Verify Python code submissions and auto-generate meaningful feedback messages.
高级语言: Python
项目地址: git://github.com/datacamp/pythonwhat.git
创建时间: 2016-02-09T10:53:56Z
项目社区:https://github.com/datacamp/pythonwhat

开源协议:GNU Affero General Public License v3.0

下载


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

  1. # latest stable version from PyPi
  2. pip install pythonwhat
  3. # latest development version from GitHub
  4. 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.

  1. # make all checking functions available
  2. from pythonwhat.test_exercise import prep_context
  3. _, ctxt = prep_context()
  4. globals().update(ctxt)
  5. # initialize state with student and solution submission
  6. from pythonwhat.test_exercise import setup_state
  7. setup_state(stu_code = "x = 5", sol_code = "x = 4")
  8. Ex().check_object('x')
  9. # No error: x is defined in both student and solution process
  10. Ex().check_object('x').has_equal_value()
  11. # TestFail: Did you correctly define the variable `x`? Expected `4`, but got `5`.
  12. # Debugging state
  13. Ex()._state # access state object
  14. dir(Ex()._state) # list all elements available in the state object
  15. 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

  1. pyenv local 3.9.6
  2. pip3.9 install -r requirements-test.txt
  3. pip3.9 install -e .
  4. pytest

Contributing

Bugs? Questions? Suggestions? Create an issue, or engineering@datacamp.com">contact us!

License

FOSSA Status