Skip to content

EndurantDevs/webtest-sanic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webtest-sanic

Integration of WebTest with Sanic applications Initially it was created to enable Sanic support in Webargs module

Build Status Latest Version Python Versions Tests Coverage

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 [email protected]: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.

About

Integration of WebTest with Sanic applications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages