用于httpsrv的vcr录制代理服务器
httpsrvvcr的Python项目详细描述
用于将http请求记录为yaml格式的库,可以是 将httpsrv进一步理解为服务器设备
安装
可从PYPI获得包裹
pip install httpsrvvcr
用法
基本用法如下:
python -m httpsrvvcr.recorder 8080 http://some-api-url.com/api > tape.yaml
可以跳过带有--no-headers标志的标题录制:
python -m httpsrvvcr.recorder 8080 http://some-api-url.com/api --no-headers > tape.yaml
once还可以从输出中完全排除一些请求方法:
python -m httpsrvvcr.recorder 8080 http://some-api-url.com/api --skip-methods OPTIONS TRACE > tape.yaml
录制VCR磁带后,可以使用httpsrvvcr.player模块:
import unittest from httpsrv import Server from httpsrvvcr.player import Player server = Server(8080).start() player = Player(server) class MyTestCase(unittest.TestCase): def setUp(self): server.reset() @player.load('path/to/tape.yaml') def test_should_do_something(self): pass