Skip to main content

Python的提交正确性测试

项目描述

蟒蛇什么

构建状态 PyPI 版本 文件状态 福萨状态

验证 Python 代码提交并自动生成有意义的反馈消息。最初是为 DataCamp 上的 Python 练习开发的,用于所谓的提交正确性测试,但也可以独立使用。

安装

# 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.txt
pip3.9 install -e .
pytest

贡献

虫子?问题?建议?创建问题,或联系我们

执照

福萨状态

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

tcs_pythonwhat-2.24.21.tar.gz (151.1 kB 查看哈希

已上传 source