Skip to main content

Behave Web Api

Build Status Version

Provides testing for JSON APIs with Behave [1]

Requires Python 3.11 or newer.

Installation

uv add behave-web-api

Import steps in your features/steps/__init__.py

from behave_web_api.steps import *

So you can use the steps in your feature files

Feature: Doing http requests

  Scenario: Send text body and headers
    Given I set header "X-My-Header" with value "Something"
    And I set header "Content-Type" with value "application/json"
    When I send a POST request to "/requests/echo" with body:
    """
    {
        "a": 1,
        "b": "",
        "c": "0101",
        "d": "[01]+"
    }
    """
    Then the response code should be 200
    And the response should contain json:
    """
        {
            "headers": {
                "X-My-Header": "Something"
            },
            "body": {
                "a": "<is_number>",
                "b": "%.*%",
                "c": "%[01]+%",
                "d": "[01]+"
            }
        }
    """

  Scenario: Send file using variables and environment variables
    Given I set the variable "DATA_DIR" with value "$PWD/features/data"
    And I attach the file "$DATA_DIR/favicon.ico" as "upload"
    When I send a POST request to "/requests/echo"
    Then the response code should be 200
    And print response

And run using BASE_URL environment variable:

BASE_URL=localhost:5000 behave features/requests.feature

Available Steps

  • Given I set variable “{}” with value “{}”

  • Given I set header “{}” with value “{}”

  • Given I attach the file “{}” as “{}”

  • When I send a {} request to “{}” with body:

  • When I send a {} request to “{}” with values:

  • When I send a {} request to “{}”

  • Then the response code should be {}

  • Then the response should contain json:

  • Then the response should contain text:

  • Then print response

Acknowledgments

The REST steps are based on Behat WebApiExtension [2]

Metadata

Release files for behave-web-api 2.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for behave-web-api 2.4.0
File Size Uploaded Provenance Actions
behave_web_api-2.4.0.tar.gz 9.2 kB Without provenance Details for behave_web_api-2.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for behave-web-api 2.4.0
File Interpreter ABI Platform Actions
behave_web_api-2.4.0-py3-none-any.whl Python 3 none any Details for behave_web_api-2.4.0-py3-none-any.whl

Total release size: 16.8 kB

Release files / behave_web_api-2.4.0.tar.gz

Download URL behave_web_api-2.4.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
17ffc90679cf7e68523df0253ff78f345afc1e000a9e8fbeb13597a348c7e761
BLAKE2b-256 checksum
How to use checksums
697034c065582683054c6ceedcc5bd9c315ecf6e6813f30cf70ca3526a585553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / behave_web_api-2.4.0-py3-none-any.whl

Download URL behave_web_api-2.4.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
768f43f83feb03189802e9219df505cae00148c4b8e4b38f9e72e14e32e1e9f8
BLAKE2b-256 checksum
How to use checksums
8d2d3a074dcd879a45d0f2a19e886e938964602df7e7146133d8a2e1aad14a9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for behave-web-api 2.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page