Skip to content

sloria/webtest-asgi

Repository files navigation

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

Project Links

License

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

About

Integration of WebTest with ASGI applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages