磁带存储和重放http请求。

cassette的Python项目详细描述


卡式磁带存储和回放在python应用程序中发出的http请求。

importurllib2importcassettewithcassette.play("data/responses.yaml"):# If the request is not already stored in responses.yaml, cassette# will request the URL and store its response in the file.r=urllib2.urlopen("http://www.internic.net/domain/named.root")# This time, the request response must be in the file. The external# request is not made. cassette retrieves the response from the# file.r=urllib2.urlopen("http://www.internic.net/domain/named.root")assert"A.ROOT-SERVERS.NET"inr.read(10000)

盒式磁带还支持requests 图书馆。

importrequestswithcassette.play("data/responses.yaml"):r=requests.get("http://www.internic.net/domain/named.root")

请注意,存储在不同库之间的请求可能与 彼此。也就是说,使用urllib2存储的请求可能仍然会触发外部 请求与使用requests请求的URL相同。

安装

$ pip install cassette

文档

最新文档:cassette.readthedocs.org

许可证

根据麻省理工学院的许可证,盒式磁带是可以买到的。

Uber 2013版权所有,Charles Axel Dein,charles@uber.com>;

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
字符串Java字母替换无效   java Spring Roo JPA MS SQL Server无法打开JPA EntityManager组织。冬眠例外GenericJDBCException:无法打开连接   在scala中使用JavaWS对大型数据文件进行java流式处理   Java编译器是否将字节和短字符识别为文本?   java无法查找符号错误,空指针   mongodb在Java中重用数据库连接   java将多个StringArray从字符串文件获取到活动中   java是一个变量,它只保存最后一次鼠标单击的坐标   c#尺寸有限;添加、删除和洗牌   java如何在Android中显示来自资产文件夹的文本文件中的文本   Android应用程序中的java Tensorflow Lite自定义对象检测模型错误   java如何在foreachloop中使用scanner将来自命令行的输入存储到数组中   java如何定义一个好的存储库接口   Android中的java解析动态json对象