pytest plugin for test session metadata
Project description
pytest-metadata is a plugin for pytest that provides access to test session metadata.
Requirements
You will need the following prerequisites in order to use pytest-metadata:
Python 2.7, 3.6, PyPy, or PyPy3
pytest 2.9.0 or newer
Installation
To install pytest-metadata:
$ pip install pytest-metadata
Available metadata
The following metadata is gathered by this plugin:
Key |
Description |
Example |
---|---|---|
Python |
Python version |
3.6.0 |
Platform |
Platform |
Darwin-16.4.0-x86_64-i386-64bit |
Packages |
pytest packages |
{‘py’: ‘1.4.33’, ‘pytest’: ‘3.0.7’} |
Plugins |
pytest plugins |
{‘metadata’: ‘1.3.0’} |
Additional metadata
You can provide your own metadata (key, value pair) by specifying --metadata on the commandline:
pytest --metadata foo bar
Note: You can provide multiple sets of --metadata:
pytest --metadata foo bar --metadata baz zoo
Continuous integration
When run in a continuous integration environment, additional metadata is added from environment variables. Below is a list of the supported continuous integration providers, along with links to the environment variables that are added to metadata if they’re present.
Note that if you’re using Tox to run your tests then you will need to pass down any additional environment variables for these to be picked up.
Accessing metadata
To access the metadata from a test or fixture, you can use the metadata fixture:
def test_metadata(metadata):
assert 'metadata' in metadata['Plugins']
To access the metadata from a plugin, you can use the _metadata attribute of the config object. This can be used to read/add/modify the metadata:
def pytest_configure(config):
if hasattr(config, '_metadata'):
config._metadata['foo'] = 'bar'
Plugin integrations
Here’s a handy list of plugins that either read or contribute to the metadata:
pytest-base-url - Adds the base URL to the metadata.
pytest-html - Displays the metadata at the start of each report.
pytest-selenium - Adds the driver, capabilities, and remote server to the metadata.
Resources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_metadata-1.4.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e8411540925d715195e2b4d2e11302ea0a1f37c20b3f1438a0df3b77085e4d1 |
|
MD5 | ba9099cb68d1e3d852b1661343e00021 |
|
BLAKE2b-256 | 57c60797e6e6b04211787b43a9633939b4b9ef41999df43332da4ed3872d2db1 |