Skip to main content

pytest-azurepipelines

PyPI version Python versions PyPI download month https://anaconda.org/conda-forge/pytest-azurepipelines/badges/version.svg

Making Pytest easier to use with Microsoft Azure Pipelines.

Just run pytest with this plugin and see your test results in the Azure Pipelines UI!


Features:

  • Formats the PyTest output to show test docstrings and module names instead of just test case names in the Azure Pipelines UI.

  • Uploads test results automatically, no need for a separate test results upload command

  • Displays the number of failed tests if there were failures as an error message in the UI

  • Automatically formats code coverage and uploads coverage data if pytest-cov is installed

  • Supports running inside a Docker container and automatically uploads test results

Installation

You can install “pytest-azurepipelines” via pip from PyPI:

$ pip install pytest-azurepipelines

Usage

This plugin requires no configuration.

Here is an example of installing the plugin and running the tests.

- script: |
    python -m pip install --upgrade pip
    pip install pytest pytest-azurepipelines
    pip install -e .
  displayName: 'Install dependencies'

- script: |
    python -m pytest tests/
  displayName: 'pytest'

If you want to change the Azure Pipelines “Test Run Title”, you can provide the –test-run-title flag with the run title.

- script: |
    pip install pytest pytest-azurepipelines
    pytest tests/ --test-run-title="Windows Test"

If you have long docstrings in your functions and want them to be shortened, you can use the –napoleon-docstrings flag:

- script: |
   pip install pytest pytest-azurepipelines
   pytest tests/ --test-run-title="Windows Test" --napoleon-docstrings

The directory where the html reports are searched for can be changed with the –report-dir flag. It defaults to htmlcov:

- script: |
   pip install pytest pytest-azurepipelines
   pytest tests/ --report-dir=custom_folder

Fixtures

The following fixtures are made available by this plugin.

record_pipelines_property

Calling record_pipelines_property(key: str, value: str) will result in Property tags being added to the test-case for the related node.

def test_basic(record_pipelines_property):
    record_pipelines_property("test", "value")
    assert 1 == 1

add_pipelines_attachment

Add an attachment to a node test-case by calling the add_pipelines_attachment(path: str, description: str) function with the filepath and a description.

Attachments can be viewed in the Azure Pipelines UI under the ‘Attachments’ tab for a test case.

def test_attachment(add_pipelines_attachment):
    pth = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'fixture.gif')
    add_pipelines_attachment(path, "peanut butter jelly time")
    assert 1 == 1

Using the automatic code coverage upload

From version 0.6.0, pytest will upload successful coverage data into a format that Azure supports and package the htmlcov directory into a ZIP file as an artifact for the build.

To use this feature, add the –cov flag with (optional, but required) path to your code files and also ensure you add –cov-report html as an option.

- script: |
   pip install pytest pytest-azurepipelines pytest-cov
   pytest tests/ --cov my_project --cov-report html

To disable coverage upload, use the –no-coverage-upload flag.

Running in Docker

The plugin automatically detects when running inside a docker container. It will apply the mappings to the path to report them back to Azure Pipelines using the path from the host that has been bind mounted to the docker container.

No configuration is required if bind mounting is used to the path the pytest output is written to. Also ensure the files are written using an account the host has access to, this can be done by supplying the user and group of the host account to the run command.

docker run --user "$(id -u):$(id -g)" ...

To disable docker discovery, use the –no-docker-discovery flag.

Contributing

Contributions are very welcome.

License

Distributed under the terms of the MIT license, “pytest-azurepipelines” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Metadata

Release files for pytest-azurepipelines 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-azurepipelines 1.0.5
File Size Uploaded Provenance Actions
pytest-azurepipelines-1.0.5.tar.gz 9.7 kB Without provenance Details for pytest-azurepipelines-1.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-azurepipelines 1.0.5
File Interpreter ABI Platform Actions
pytest_azurepipelines-1.0.5-py3-none-any.whl Python 3 none any Details for pytest_azurepipelines-1.0.5-py3-none-any.whl

Total release size: 19.4 kB

Release files / pytest-azurepipelines-1.0.5.tar.gz

Download URL pytest-azurepipelines-1.0.5.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fd08f089bca0fad3c2b6fde9dbea69b975492ffaa8cb637cc987e64af8c18b9c
BLAKE2b-256 checksum
How to use checksums
3d9fd2ed8e69421cc770c2f807778eb08882a4fd320c8eebf53370320445a368
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.1

Release files / pytest_azurepipelines-1.0.5-py3-none-any.whl

Download URL pytest_azurepipelines-1.0.5-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58b65a7a47710cea46a310f6c0222b0b2ecaa35c9eabbb9a027666726c52f914
BLAKE2b-256 checksum
How to use checksums
e6cfeafce53880a58c162a69a5cd0cbefabb778233d8a879cbf8f897c9097cf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.1

Security for pytest-azurepipelines 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page