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
Built Distribution
File details
Details for the file webtest-asgi-1.1.0.tar.gz
.
File metadata
- Download URL: webtest-asgi-1.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fd0500e4526bb4b90816f84a17094cfd29482c148873da4243b953b9ab187e1 |
|
MD5 | 46ecde512290cea7c6a0b84e9c99c9e5 |
|
BLAKE2b-256 | 9c8e8e433d19969714853240173cbba717f7d34a2b221f1e01b167520eacfe89 |
Provenance
File details
Details for the file webtest_asgi-1.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: webtest_asgi-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c550fdaed0e349395389ba990a7d445fe307d116f4cd2e96a9378026825350fe |
|
MD5 | 5cfa61751bf157f835d530eee9742861 |
|
BLAKE2b-256 | 2b78432e9dd2f7f0f748c2edf9572c9a0c890b3dae37bd429c8a7c7400cf968f |