跳转到主要内容

flask-httpretty 帮助您通过 Flask 模拟 HTTP 请求。

项目描述

https://travis-ci.org/admire93/flask-httpretty.svg?branch=master

使用 Flask 模拟 HTTP 请求!

flask-httpretty 基于 httpretty 构建。

你好,世界

from flask import Flask
from urllib.request import urlopen

import flask_httpretty


app = Flask(__name__)


@app.route('/', methods=['GET'])
def hello_world():
    return 'hello world'


@flask_httpretty.activate
def test_hello_world():
    flask_httpretty.register_app(app, 'http://hellotest.com')
    resp = urlopen('http://hellotest.com').read()
    assert 'hello world' == resp.decode('utf-8')

官方支持的库

由于 flask-httpretty 使用 httpretty 来猴子补丁 Python 的 socket,因此它支持与 httpretty 相同的库 httpretty 支持。这些都是

项目详情


下载文件

下载适合您平台的应用程序。如果您不确定要选择哪一个,请了解有关 安装包 的更多信息。

源代码发行版

Flask-httpretty-1.3.0.tar.gz (4.4 kB 查看散列)

上传时间: 源代码

构建发行版

Flask_httpretty-1.3.0-py2.py3-none-any.whl (7.2 kB 查看散列)

上传时间: Python 2 Python 3

由以下提供支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页面