flask httpretty帮助您通过flask模拟http请求。
Flask-httprett的Python项目详细描述
用烧瓶模拟http请求!
烧瓶httpretty是基于httpretty构建的。
你好,世界
fromflaskimportFlaskfromurllib.requestimporturlopenimportflask_httprettyapp=Flask(__name__)@app.route('/',methods=['GET'])defhello_world():return'hello world'@flask_httpretty.activatedeftest_hello_world():flask_httpretty.register_app(app,'http://hellotest.com')resp=urlopen('http://hellotest.com').read()assert'hello world'==resp.decode('utf-8')