Skip to main content

Formatting PyTest output for Azure Pipelines UI

Project description

Build status PyPI version Python versions

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.

  • Overloads the –junit-xml flag on execution with a default value

  • Uploads test results automatically, no need for a seperate 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

https://github.com/tonybaloney/pytest-azurepipelines/raw/master/screenshot.png

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 with junitxml"
  displayName: 'pytest with junitxml flag'

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 with junitxml" --napoleon-docstrings

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-azurepipelines-0.6.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

pytest_azurepipelines-0.6.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest-azurepipelines-0.6.0.tar.gz.

File metadata

  • Download URL: pytest-azurepipelines-0.6.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pytest-azurepipelines-0.6.0.tar.gz
Algorithm Hash digest
SHA256 0df7ee37f2283e8e17059996b7269b882ed682c3921f1590cfd440c6a3bd40a0
MD5 99dc956d5ddfca2753f964d17e4acc69
BLAKE2b-256 9083b3c08b22dbdd482797c52d09e778cd411230902f33253cd362794dc1e8a9

See more details on using hashes here.

File details

Details for the file pytest_azurepipelines-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_azurepipelines-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pytest_azurepipelines-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71ad8d0c058800639951b3cefc9201b1df6790342a0982029b19631aea01d11a
MD5 eab123d06c9a8d6d88e661ffd3ab8d6e
BLAKE2b-256 18cd5931a8f4fa228086a2dd0459226c72fee79f4877249859f48a1a5266a8fc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page