httprunner环境搭建

httprunner中文使用手册:http://cn.httprunner.org/

根据httprunner中文使用手册进行的部署,emm.....但是总在踩坑的路上

1、python3环境搭建

$ brew install pyenv   (brew/pip都需要自己安装才可以使用,非自带)

brew安装命令行   : 

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

$ pyenv -V       检查是否安装成功

$ pyenv insatll --list         找到可以安装的python版本,选择大于3.6版本安装(我的3.6.4)

$ pyenv local 3.6.4          切换python版本,将3.6.4设为本地默认版本

但是这个情况有点懵:

httprunner环境搭建_第1张图片

$ pyenv versions 

同样是查看版本信息的,这是几个意思啊???(感谢ying的解答)

pyenv是python的环境管理,pyenv versions是查Python的已安装版本,pyenv -v是查pyenv本身的版本 ,所以出现上面的图说明python3环境成功了

2、安装最新的开发版本:(以下任选其一)

$ pip install httprunner

$ pip install git+https://github.com/HttpRunner/HttpRunner.git#egg=HttpRunner

3、安装依赖(Debug模式):

$ pip3  install pipenv

httprunner环境搭建_第2张图片

显示没有权限,那就chmod 

$ sudo chmod 777 /usr/local/bin/pipenv

获取git的源码:

$ git clone https://github.com/HttpRunner/HttpRunner.git

$ pipenv install --dev

httprunner环境搭建_第3张图片

这块也不知道是什么意思?

运行单元测试,测试单元都跑通说明安装成功

$ pipenv run python -m unittest discover

查看httprunner的依赖关系

$ pipenv graph

4、启动服务

在httprunner 中已经有开发者写好的案例文件,存储于 HttpRunner 的单元测试目录中,路径为tests/api_server.py

可以用这个案例文件来进行Demo,采用flask应用服务启动

$ export FLASK_APP=tests/api_server.py

$ flask run

* Serving Flask app "tests.api_server"

* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

httprunner环境搭建_第4张图片

额欧,Debug模式显示off。。。。服务器没有起

然后需要更改配置文件

$ vi ~/.bash_profile

添加内容:

export FLASK_ENV=development

flask run

保存退出后 source ~/.bash_profile 使环境变量生效

httprunner环境搭建_第5张图片

啊啊啊啊,终于。。。。

到这里的环境搭建就结束了,不难,但是坑多多~~

你可能感兴趣的:(httprunner环境搭建)