webtest-asgi提供WebTest与ASGI应用程序的集成
项目描述
webtest-asgi提供WebTest与ASGI应用程序的集成。
免责声明
您可能应该使用Starlette的TestClient而不是此包来测试ASGI应用程序。此包是为了使用webargs的CommonTestCase测试webargs-starlette而创建的,它使用WebTest测试多个Web框架中的公共功能。
安装
pip install webtest-asgi
用法
您可以使用webtest-asgi与任何ASGI应用程序。以下是与Starlette一起使用的示例用法。
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from webtest_asgi import TestApp as WebTestApp
app = Starlette()
@app.route("/")
async def homepage(request):
return JSONResponse({"hello": "world"})
@pytest.fixture()
def testapp():
return WebTestApp(app)
def test_get_homepage(testapp):
assert testapp.get("/").json == {"hello": "world"}
项目链接
许可证
MIT许可。有关更多详细信息,请参阅捆绑的LICENSE文件。
项目详情
关闭
webtest-asgi-1.1.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7fd0500e4526bb4b90816f84a17094cfd29482c148873da4243b953b9ab187e1 |
|
MD5 | 46ecde512290cea7c6a0b84e9c99c9e5 |
|
BLAKE2b-256 | 9c8e8e433d19969714853240173cbba717f7d34a2b221f1e01b167520eacfe89 |
关闭
webtest_asgi-1.1.0-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c550fdaed0e349395389ba990a7d445fe307d116f4cd2e96a9378026825350fe |
|
MD5 | 5cfa61751bf157f835d530eee9742861 |
|
BLAKE2b-256 | 2b78432e9dd2f7f0f748c2edf9572c9a0c890b3dae37bd429c8a7c7400cf968f |