webtest asgi提供了webtest与asgi应用程序的集成
webtest-asgi的Python项目详细描述
webtest asgi提供了WebTest与ASGI应用程序的集成。
安装
pip install webtest-asgi
用法
您可以将webtest asgi与任何asgi应用程序一起使用。下面是使用Starlette的示例。
fromstarlette.applicationsimportStarlettefromstarlette.responsesimportJSONResponsefromwebtest_asgiimportTestAppasWebTestAppapp=Starlette()@app.route("/")asyncdefhomepage(request):returnJSONResponse({"hello":"world"})@pytest.fixture()deftestapp():returnWebTestApp(app)deftest_get_homepage(testapp):asserttestapp.get("/").json=={"hello":"world"}
许可证
麻省理工学院许可。有关详细信息,请参见捆绑的LICENSE文件。