webtest-asgi provides integration of WebTest with ASGI applications
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
webtest-asgi-1.1.0.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for webtest_asgi-1.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c550fdaed0e349395389ba990a7d445fe307d116f4cd2e96a9378026825350fe |
|
MD5 | 5cfa61751bf157f835d530eee9742861 |
|
BLAKE2b-256 | 2b78432e9dd2f7f0f748c2edf9572c9a0c890b3dae37bd429c8a7c7400cf968f |