skillfed

pytest-base-url

pytest plugin for URL based testing

pytest-base-url v2.1.0 10.2M downloads/30d#1,473 on PyPI39
Copyleft license Active released

What it is and what it does

pytest-base-url is a lightweight pytest plugin that centralizes base URL management for test suites that make HTTP requests. Instead of hardcoding or repeating URLs across tests, you specify a single base URL once—via command line (--base-url), configuration file, environment variable (PYTEST_BASE_URL), or by overriding the base_url fixture—and inject it into any test that needs it. The plugin is commonly used in integration and end-to-end testing workflows where tests need to target different environments (dev, staging, production) without code changes.

The package depends only on pytest and requests, making installation frictionless. It supports Python 3.8 and later on CPython and PyPy, and is actively maintained. An optional --verify-base-url flag lets you fail fast if the target URL is unreachable before running the full suite, and you can conditionally skip tests based on the base URL value.

Use it for:

  • Integration testing against multiple environments by passing different base URLs without changing test code
  • End-to-end testing of web applications where the server URL is determined at runtime by a fixture
  • CI/CD pipelines that run the same test suite against dev, staging, and production with environment-specific URLs
  • Skipping environment-specific tests (e.g., skip search tests on dev) based on the base URL provided
  • Verifying that a target URL is reachable before running a large test suite to fail fast on connectivity issues

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pytest plugin that injects a configurable base URL into your test suite via command line, config file, environment variable, or fixture override.

Yes. This is a mature, actively maintained plugin (Production/Stable status, last release January 2024) with minimal dependencies and low install friction. It solves a common testing problem elegantly and has no known vulnerabilities. The copyleft license (MPL 2.0) is permissive for most use cases. Install it if your test suite makes HTTP requests to configurable endpoints.

Install

pytest-base-url on PyPI

pip

pip install pytest-base-url

uv

uv add pytest-base-url

poetry

poetry add pytest-base-url

Installing pytest-base-url

Before you install

Low friction: pure Python wheel with only pytest and requests as runtime dependencies. Actively maintained with recent commits; last release was January 2024.

License in practice

Licensed under Mozilla Public License 2.0 (MPL 2.0), a copyleft license. You may use and modify the package freely, but derivative works must be distributed under the same license terms.

Quickstart

pip install pytest-base-url

# In your test file:
def test_example(base_url):
    import requests
    response = requests.get(base_url)
    assert response.status_code == 200

# Run with: pytest --base-url http://example.com

Requires Python 3.8 or later (or PyPy3). The base_url fixture depends on pytest being installed.

Verify before relying

  • Whether the package handles URL validation or normalization beyond what the description states
  • Performance impact of base URL verification with --verify-base-url on large test suites
  • Compatibility details with pytest versions beyond the classifiers listed

Package facts

License not declared (copyleft)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 2 — pytest, requests
Maintenance actively maintained — 926 days since the last release
Last repo commit
First released
Downloads 10,189,946/month — #1,473 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_base_url-2.1.0-py3-none-any.whl

Keywords: automation, base, mozilla, pytest, url

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Natural Language :: EnglishOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTopic :: Utilities

Tags

pytest base url fixturepytest url configuration pluginpytest command line base urlpytest environment variable urlpytest test url managementpytest url testing helperpytest base url override
pytest-pluginintegration-testingurl-management

More Utilities packages