def test_httplib2_in_out():
hostname = str(uuid4())
port = 9999
url = 'http://%s:%s/' % (hostname, port)
http = Http()
with Httplib2Interceptor(app=app, url=url) as target_url:
response, content = http.request(target_url)
assert response.status == 200
assert 'WSGI intercept successful!' in content.decode('utf-8')
# outside the context manager the intercept does not work
with py.test.raises(ServerNotFoundError):
http.request(url)
# Requests
test_interceptor.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录