Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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

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

asgi starlette testing webtest

Last synced: 3 days 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: pypi badge
:target: https://pypi.org/project/webtest-asgi/

.. image:: https://badgen.net/travis/sloria/webtest-asgi/master
:alt: travis-ci status
:target: https://travis-ci.org/sloria/webtest-asgi

.. image:: https://badgen.net/badge/code%20style/black/000
:target: https://github.com/ambv/black
:alt: 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 `_.

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