Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Behave HTTP steps

Project Description

A Python package for HTTP-service testing. Contains reusable steps for Behave BDD (behaviour-driven development) tool. It’s mostly useful for testing REST APIs and interacting with JSON data over HTTP.



from behave_http.environment import before_scenario


from behave_http.steps import *

(You can mix them with your own steps in the same file.)


Feature: Some API
  As an API client
  I want to be able to manage activities and sessions

  Background: Set server name, headers and reset test user's database
    Given I am using server "$SERVER"
    And I set base URL to "$URL"
    And I set "Accept" header to "application/json"
    And I set "Content-Type" header to "application/json"
    And I set BasicAuth username to "" and password to "t"

  Scenario: Ensure account exists
    When I make a GET request to "account"
    Then the response status should be 200

If your test target is you can test it with:

SERVER= URL=api behave

General rules on using quoted "values" in feature files:

  • JSONs and numbers (response code, array length) must appear as is.
  • Other substitutes must be quoted (variable names, headers and their values).

While there is no extensive documentation the features (self tests) directory contains (a hopefully complete) set of usage examples.

Testing for nested JSON content with non-ASCII characters in paths is not supported by the underlying ``jpath`` library.


To install essential packages for the test suite:

pip install -r requirements_dev.txt

A complete list of development tools used in the Makefile can be installed with:

pip install coveralls docutils flake8 tox wheel

Running tests

Launch a special HTTP server responding to test requests:


Then run feature tests in a separate shell:

make test-all # runs on every supported python version with tox
make test     # runs in current python environment only

Environment variables

Set TEST_SERVER to full URL (including schema) if default port (55080) on localhost is already used by another process. For example:

python >testserver.log 2>&1 &
make test-coverage


The REST steps code is initially derived from rest api blueprint [1], so this project inherits the same BSD 2-Clause License (see LICENSE file).


Release History

This version
History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(8.8 kB) Copy SHA256 Hash SHA256
Wheel py2.py3 Nov 9, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting