pytest-base-url
pytest plugin for URL based testing
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-urluv
uv add pytest-base-urlpoetry
poetry add pytest-base-urlInstalling 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
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytest-metadataA pytest plugin that captures and exposes test…
copyleft · top 1,000 on PyPI
pytest-seleniumpytest-selenium is a pytest plugin that…
copyleft · top 15,000 on PyPI
pytest-httpbinProvides a pytest fixture that runs a local…
permissive · top 15,000 on PyPI
pytest-djangopytest-django integrates Django with pytest,…
permissive · top 1,000 on PyPI
pytest-postgresqlA pytest plugin that provides fixtures to…
copyleft · top 5,000 on PyPI
pytest-localserverProvides pytest fixtures that spin up local…
permissive · top 15,000 on PyPI
pytest-sparkA pytest plugin that integrates Apache Spark…
permissive · top 15,000 on PyPI
pytest-htmlGenerates HTML reports for pytest test results,…
copyleft · top 1,000 on PyPI
pytest-sftpserverA pytest plugin that provides a fixture for…
permissive · top 5,000 on PyPI
pytest-loguruExtends pytest's caplog fixture to capture and…
permissive · top 15,000 on PyPI