An open API service indexing awesome lists of open source software.

https://github.com/sloria/webtest-asgi

Integration of WebTest with ASGI applications.
https://github.com/sloria/webtest-asgi

asgi starlette testing webtest

Last synced: 7 months ago
JSON representation

Integration of WebTest with ASGI applications.

Awesome Lists containing this project

README

          

************
webtest-asgi
************

.. image:: https://badgen.net/pypi/v/webtest-asgi
:alt: Latest version
:target: https://pypi.org/project/webtest-asgi/

.. image:: https://github.com/sloria/webtest-asgi/actions/workflows/build-release.yml/badge.svg
:alt: Build status
:target: https://github.com/sloria/webtest-asgi/actions/workflows/build-release.yml

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 `_.

.. code-block:: python

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
=============

- PyPI: https://pypi.python.org/pypi/webtest-asgi
- Issues: https://github.com/sloria/webtest-asgi/issues

License
=======

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