Skip to main content

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

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 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webtest-sanic-0.3.0.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file webtest-sanic-0.3.0.tar.gz.

File metadata

  • Download URL: webtest-sanic-0.3.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.9.1

File hashes

Hashes for webtest-sanic-0.3.0.tar.gz
Algorithm Hash digest
SHA256 32c48160c16297b40364ddec41c0e7c542dda4c0a5c725dd1de4cd220a1a4bb1
MD5 41c2c3295e3e45c71abdc26ae537d7c0
BLAKE2b-256 d95017798532f7adc4f6940c0695b6e79864460da82af986cb0e44db71f1e47b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page