https://github.com/endurantdevs/webtest-sanic
Integration of WebTest with Sanic applications
https://github.com/endurantdevs/webtest-sanic
python sanic sanic-framework webtest
Last synced: 10 days ago
JSON representation
Integration of WebTest with Sanic applications
- Host: GitHub
- URL: https://github.com/endurantdevs/webtest-sanic
- Owner: EndurantDevs
- License: mit
- Created: 2018-09-15T17:11:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-09-06T09:19:38.000Z (over 4 years ago)
- Last Synced: 2026-01-14T10:34:41.077Z (5 months ago)
- Topics: python, sanic, sanic-framework, webtest
- Language: Python
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# webtest-sanic
Integration of [WebTest](https://github.com/Pylons/webtest) with [Sanic](https://github.com/huge-success/sanic) applications
Initially it was created to enable Sanic support in [Webargs](https://github.com/sloria/webargs) module
[](https://app.travis-ci.com/EndurantDevs/webtest-sanic) [](https://pypi.python.org/pypi/webtest-sanic/) [](https://github.com/EndurantDevs/webtest-sanic/blob/master/setup.py) [](https://codecov.io/gh/EndurantDevs/webtest-sanic)
### Example Code ###
```python
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](https://github.com/sloria/webtest-aiohttp) by [Steven Loria](https://github.com/sloria) and [pytest-sanic](https://github.com/yunstanford/pytest-sanic) by [Yun Xu](https://github.com/yunstanford)
Please check [NOTICE](NOTICE.md) for more info.