sloria / webtest-asgi

Integration of WebTest with ASGI applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

webtest-asgi

pypi badge

travis-ci status

Code style: Black

webtest-asgi provides integration of WebTest with ASGI applications.

Disclaimer

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.

Installation

pip install webtest-asgi

Usage

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"}

License

MIT licensed. See the bundled LICENSE file for more details.

About

Integration of WebTest with ASGI applications.

License:MIT License


Languages

Language:Python 100.0%