webtest-asgi provides integration of WebTest with ASGI applications.
You should probably use Starlette's TestClient
instead of this package for testing ASGI applications.
This package was created to test webargs-starlette using
webargs' CommonTestCase
, which uses WebTest to test common
functionality across multiple web frameworks.
pip install webtest-asgi
You can use webtest-asgi with any ASGI application. Here is example usage with 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"}
- PyPI: https://pypi.python.org/pypi/webtest-asgi
- Issues: https://github.com/sloria/webtest-asgi/issues
MIT licensed. See the bundled LICENSE file for more details.