pytest-base-url is a simple plugin for pytest that provides an optional base
URL via the command line or configuration file.
Requirements
You will need the following prerequisites in order to use pytest-base-url:
Python 3.8+ or PyPy3
Installation
To install pytest-base-url:
$ pip install pytest-base-url
Contributing
We welcome contributions.
To learn more, see Development
Specifying a Base URL
Rather than repeating or abstracting a base URL in your tests, pytest-base-url
provides a base_url fixture that returns the specified base URL.
import urllib2
def test_example(base_url):
assert 200 == urllib2.urlopen(base_url).getcode()
Using the Command Line
You can specify the base URL on the command line:
$ pytest --base-url http:/www.example.com
Using a Configuration File
You can specify the base URL using a configuration file:
[pytest]
base_url = http:/www.example.com
Using an Environment Variable
You can specify the base URL by setting the PYTEST_BASE_URL environment var
|