Ecosyste.ms: Awesome
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: 3 days ago
JSON representation
Integration of WebTest with ASGI applications.
- Host: GitHub
- URL: https://github.com/sloria/webtest-asgi
- Owner: sloria
- License: mit
- Created: 2019-01-02T23:27:59.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-21T05:05:27.000Z (about 2 years ago)
- Last Synced: 2025-01-10T19:12:44.514Z (14 days ago)
- Topics: asgi, starlette, testing, webtest
- Language: Python
- Homepage:
- Size: 47.9 KB
- Stars: 6
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.md
- License: LICENSE
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: Blackwebtest-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 WebTestAppapp = 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/issuesLicense
=======MIT licensed. See the bundled `LICENSE `_ file for more details.