Skip to main content

A simple plugin to use with pytest

Project description

PyPI version Python versions See Build Status on Travis CI See Build Status on AppVeyor

pytest plugin providing a BDD ‘language’ for web app integration-testing.


Implements a simple headless browser that requests web pages according to a URL mapping, parses web forms, and enables assertions about the various web responses using PyQuery selectors (similar to jQuery).


Feature: Homepage functionality
    Scenario: Homepage
        When the user requests list home
        Then response 0 status code is "200"
        And response 0 element "#main_title" contains 'Welcome'

    Scenario: User profile
        When the user requests view user_profile
        Then response 0 status code is "200"
        And response 0 element "tr:contains('Balance')" contains '45.67'
        And response 0 form-contains-array-outline <arrayfield> <arrayvalue>

        | arrayfield | arrayvalue |
        | choices    | [0 2 3]    |

Requires you to provide these fixtures:

  • client
  • url_mapping

client must implement get and post methods, compatible with Flask.test_client.


def app():
    """Create, configure a new app instance for each test."""
    return app

def client(app):
    return app.test_client()

url_mapping must be a dictionary, with keys of top-level “groups”, and values mapping a human-readable “action” to an absolute URL in your web app.


    'home': {
        'list': '/',
        'articles': '/latest/',
    'user_profile': {
        'view': '/user/profile/',
        'update': '/user/profile/update',
    'blog': {
        'delete': '/blog/{}/delete', # {} gets filled from feature args
def url_mapping():
    return URL_MAPPING


PyQuery, pytest-bdd, mechanize


You can install “pytest-bdd-web” via pip from PyPI:

$ pip install pytest-bdd-web


Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.


Distributed under the terms of the MIT license, “pytest-bdd-web” is free and open source software


If you encounter any problems, please file an issue along with a detailed description.

Project details

Download files

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

Files for pytest-bdd-web, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size pytest_bdd_web-0.1.0-py3-none-any.whl (6.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pytest-bdd-web-0.1.0.tar.gz (5.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page