webtest-sanic provides integration of WebTest with sanic applications
Project description
webtest-sanic
Integration of WebTest with Sanic applications Initially it was created to enable Sanic support in Webargs module
Example Code
import asyncio
from sanic import Sanic
from sanic.response import json
from webtest_sanic import TestApp
app = Sanic()
@app.route('/')
async def test(request):
return json({'hello': 'world'})
loop = asyncio.new_event_loop()
def test_hello():
client = TestApp(app, loop=loop)
res = client.get('/')
assert res.status_code == 200
assert res.json == {'message': 'Hello world'}
Installing
It is easy to do from pip
pip install webtest-sanic
or from sources
git clone git@github.com:EndurantDevs/webtest-sanic.git
cd webtest-sanic
python setup.py install
Running the tests
To be sure everything is fine before installation from sources, just run:
python setup.py test
Or
pytest tests/
Credits
This code is based on webtest-aiohttp by Steven Loria and pytest-sanic by Yun Xu Please check NOTICE for more info.
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for webtest_sanic-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47b0dff34b76aa1e605adbfc0e2b1f0a90a95817981de63a307acb4142d05704 |
|
MD5 | 1e9872fc98921039876fb23c6fac51b8 |
|
BLAKE2b-256 | 1bb3c6b2e226c2b37d7a19a90a358a7e2d6d8958228492618b76afd52bc6de51 |