跳转到主要内容

Python提交正确性测试

项目描述

pythonwhat

Build Status PyPI version Documentation Status FOSSA Status

验证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-test.txt
pip3.9 install -e .
pytest

贡献

有虫子?问题?建议?创建一个问题,或者联系我们

许可证

FOSSA Status

项目详情


下载文件

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

源分发

pythonwhat-2.25.0.tar.gz (105.8 kB 查看哈希值)

上传时间

构建分发

pythonwhat-2.25.0-py3-none-any.whl (85.1 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面