pytest-base-url plugin

2.1.0 · active · verified Thu Apr 09

pytest-base-url is a pytest plugin that provides a `base_url` fixture for testing web applications. It allows you to define a base URL, from which derived `host` and `port` fixtures are automatically available in your tests. The current version is 2.1.0, and releases are generally tied to `pytest` compatibility or new features as needed, without a fixed cadence.

Warnings

Install

Imports

Quickstart

To quickly get started, first install the plugin. Then, configure your base URL in a `pytest.ini` file in your project's root directory under the `[pytest]` section. Finally, write your tests, making sure to declare `base_url`, `host`, or `port` as arguments in your test functions to utilize the injected fixtures.

# pytest.ini
# [pytest]
# base_url = https://api.example.com:8080/v1/

# test_example.py
def test_api_endpoint(base_url, host, port):
    assert base_url == "https://api.example.com:8080/v1/"
    assert host == "api.example.com"
    assert port == "8080"

view raw JSON →