python的提交正确性测试
pythonwhat的Python项目详细描述
Python
验证python代码提交并自动生成有意义的反馈消息。最初是为python开发的,用于datacamp上的所谓提交正确性测试,但也可以独立使用。
- 新教数据营?签出https://instructor-support.datacamp.com
- 要了解什么是sct以及它们是如何工作的,请特别访问this article。
- 有关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 availablefrompythonwhat.test_exerciseimportprep_context_,ctxt=prep_context()globals().update(ctxt)# initialize state with student and solution submissionfrompythonwhat.test_exerciseimportsetup_statesetup_state(stu_code="x = 5",sol_code="x = 4")Ex().check_object('x')# No error: x is defined in both student and solution processEx().check_object('x').has_equal_value()# TestFail: Did you correctly define the variable `x`? Expected `4`, but got `5`.# Debugging stateEx()._state# access state objectdir(Ex()._state)# list all elements available in the state objectEx()._state.student_code# access student_code of state object
要了解如何将sct包含在datacamp课程中,请访问https://instructor-support.datacamp.com。
运行测试
pyenv local3.5.2 pip install -r requirements.txt pip install -e . pytest
贡献
虫子?问题?建议?Create an issue,或者contact us!