设置代码
title: 设置代码
from hitchrunpy import ExamplePythonCode
from ensure import Ensure
import hitchbuildpy
import hitchbuild
BUILD_DIR = "/path/to/build_dir/.."
virtualenv = hitchbuildpy.VirtualenvBuild(
"/path/to/build_dir/../py3.7",
base_python=hitchbuildpy.PyenvBuild(
'/path/to/share_dir/../pyenv3.7',
"3.7",
),
)
virtualenv.verify()
pyrunner = ExamplePythonCode(
virtualenv.bin.python,
'/path/to/working_dir',
)
pyrunner.with_code((
'with open("examplefile", "w") as handle:'
' handle.write(exampletext)'
)).with_setup_code("exampletext = 'exampletext'")\
.run()
然后工作目录中的“examplefile”文件将包含
exampletext
可执行规范
从 basic.story storytests 自动生成的文档。