Skip to main content

An extension of WebTest with useful extras, including requests-style authentication.

Project description

https://badge.fury.io/py/webtest-plus.png https://travis-ci.org/sloria/webtest-plus.png?branch=master

An extension of WebTest with useful extras, including requests-style authentication.

Install

$ pip install -U webtest-plus

Usage

import unittest
from myapp import app
from webtest_plus import TestApp

class TestMyApp(unittest.TestCase):

    def setUp(self):
        self.app = TestApp(app)

    def test_protected_endpoint(self):
        response = self.app.get("/secret/", expect_errors=True)
        assert response.status_code == 401
        # Requests-style authentication
        response = self.app.get("/secret/", auth=("admin", "passw0rd"))
        assert response.status_code == 200

    def test_more_secrets(self):
        # Another way to authenticate
        self.app.authenticate(username="admin", password="passw0rd")
        assert self.app.get("/secret/").status_code == 200
        self.app.deauthenticate()
        assert self.app.get("/secret/", expect_errors=True).status_code == 401

Features

  • Basic HTTP authentication

  • Auto-follow redirects

Requirements

  • Python >= 2.6 or >= 3.3

License

MIT licensed. See the bundled LICENSE file for more details.

Changelog

0.1.0 (2013-10-06)

  • First release.

  • HTTP Basic Authentication working.

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-plus-0.1.0.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

webtest_plus-0.1.0-py2.py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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