Python提交正确性测试
项目描述
pythonwhat
验证Python代码提交并自动生成有意义的反馈信息。最初是为DataCamp上的所谓提交正确性测试而开发的Python练习,但也可以独立使用。
- 对DataCamp教学新手?请查看https://instructor-support.datacamp.com
- 要了解SCT是什么以及它们如何工作,请访问此文章。
- 要了解pythonwhat内部的所有功能以及有关何时使用的文章,请参阅https://pythonwhat.readthedocs.io。
安装
# latest stable version from PyPi
pip install pythonwhat
# latest development version from GitHub
pip install git+https://github.com/datacamp/pythonwhat
演示
要本地实验,您可以使用setup_state()
和交互式地编写SCT。当底层检查失败时,代码会抛出错误。
# 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
要了解如何在DataCamp课程中包含SCT,请访问https://instructor-support.datacamp.com。
运行测试
pyenv local 3.9.6
pip3.9 install -r requirements-test.txt
pip3.9 install -e .
pytest
贡献
许可证
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分发
pythonwhat-2.25.0.tar.gz (105.8 kB 查看哈希值)
构建分发
pythonwhat-2.25.0-py3-none-any.whl (85.1 kB 查看哈希值)