Registry / testing / pytest-azurepipelines

pytest-azurepipelines

JSON →
library1.0.5pypypi✓ verified 22d ago

pytest-azurepipelines is a plugin for the pytest testing framework that enhances its integration with Azure Pipelines. It formats pytest output to improve readability in the Azure Pipelines UI, automatically uploads test results, and integrates with pytest-cov for code coverage reporting. The current version is 1.0.5. Releases appear to be event-driven rather than on a fixed cadence, with significant updates in 2020 and 2022-2023.

pip install pytest-azurepipelines
INSTALL
IMPORT
SIG · PYTEST-AZUREPIPELI
P
pytest-azurepipelines
testingpythonv1.0.5
Install
3.8s avg
Import
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 33.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.8s · import 0.000s · 34MB
32MB installed
● package 32MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

record_pipelines_property
def test_example(record_pipelines_property): record_pipelines_property('key', 'value')
Used as a pytest fixture to add custom properties to test cases in the Azure Pipelines UI. No explicit import statement is typically needed in conftest.py or test files, as pytest discovers fixtures.
add_pipelines_attachment
import os def test_attachment_example(add_pipelines_attachment): # Create a dummy file for attachment file_path = 'temp_attachment.txt' with open(file_path, 'w') as f: f.write('This is an attachment.') add_pipelines_attachment(file_path, 'Temporary Test Data') os.remove(file_path)
Used as a pytest fixture to add attachments to test cases in the Azure Pipelines UI. Similar to record_pipelines_property, it's discovered by pytest.

Install `pytest-azurepipelines` alongside `pytest` in your Azure Pipeline environment. The plugin automatically integrates with Azure Pipelines by running `pytest` in a script step, formatting output and uploading test results without further configuration.

# Example Azure Pipelines YAML snippet steps: - script: | python -m pip install --upgrade pip pip install pytest pytest-azurepipelines pip install -e . # Install your project's test dependencies pytest tests/ displayName: 'Run Pytest with Azure Pipelines Plugin'
pytest --version
Debug
Known issues
breakingVersion 1.0.0rc3 dropped support for older Pytest releases (pre-5.0.0) and Python 2. Using `pytest-azurepipelines` with these older versions will lead to failures.
fix
Upgrade `pytest` to version 5.0.0 or higher and ensure your project uses Python 3.
affects: <1.0.0rc3
gotcha`pytest-azurepipelines` versions prior to 1.0.4 had known compatibility issues when used with `pytest-xdist` for parallel test execution. This could lead to incomplete or incorrectly reported results.
fix
Upgrade to `pytest-azurepipelines` 1.0.4 or higher to ensure proper `pytest-xdist` support. Also, ensure `pytest-xdist` itself is up-to-date.
affects: <1.0.4
gotchaWhile `pytest-azurepipelines` supports automatic code coverage upload, it requires `pytest-cov` to be installed and `--cov-report html` to be explicitly added to your `pytest` command line. Without `--cov-report html`, the HTML coverage report will not be packaged as an artifact.
fix
Install `pytest-cov` (e.g., `pip install pytest-cov`) and modify your `pytest` command to include `--cov your_project_module --cov-report html`.
affects: >=0.6.0
gotchaEach `script` block in an Azure Pipelines YAML typically runs in a new shell. If you are using Python virtual environments, you must activate the virtual environment in *each* `script` step that needs to execute Python commands to ensure correct dependency resolution.
fix
Prepend `source .venv/bin/activate` (for Linux/macOS agents) or `.venv\Scripts\activate` (for Windows agents) to each `script` block that runs Python commands after virtual environment creation.
affects: All versions when used in Azure Pipelines
gotchaUnder certain complex test setups or specific `pytest` command line arguments, the plugin might issue warnings about failing to find or publish `test-output.xml` because it attempts to process results before the file is fully written.
fix
While the plugin generally handles this, if warnings persist, simplify `junitxml` paths or ensure the `pytest` command completes successfully before any subsequent custom test result processing steps. In some cases, updating `pytest` itself can resolve underlying timing issues.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pytest_azurepipelines'
The `pytest-azurepipelines` package is not installed in the current Python environment.
fix
pip install pytest-azurepipelines
pytest-azurepipelines test results not showing in Azure DevOps
The `--azure-pipelines` flag was not included in the `pytest` command, preventing the plugin from activating its reporting and automatic result publishing.
fix
Execute pytest with the `--azure-pipelines` flag (e.g., `pytest --azure-pipelines`) to activate the plugin's reporting and automatic result publishing.
pytest-azurepipelines code coverage not showing in Azure DevOps
This often occurs due to incorrect generation of `coverage.xml` by `pytest-cov`, an incorrect path provided to the `PublishCodeCoverageResults@1` task, or misconfiguration of the code coverage task in Azure Pipelines.
fix
Ensure `pytest-cov` generates `coverage.xml` (e.g., `pytest --cov=. --cov-report=xml`) and that the `PublishCodeCoverageResults@1` task in `azure-pipelines.yml` correctly references the `summaryFileLocation` of this XML.
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x... in position ...: invalid continuation byte
Test names or output containing non-ASCII characters are being processed with an incompatible encoding, typically when the system expects UTF-8 but receives invalid bytes.
fix
Ensure your test files and test output are consistently encoded as UTF-8. Upgrading `pytest-azurepipelines` to the latest version (1.0.5) is recommended, as recent versions include improvements for handling encoding.
Upgrade
Version history
1.0.5latest on PyPI · released Oct 6, 2023
Audit
Dependencies
pytestrequiredCore testing framework this plugin extends.
pytest-covoptionalRequired for automatic code coverage upload and reporting features.
Agent activity
37 hits · last 30 days
node
30
OpenAI (training)
1
Resources
pytest-azurepipelines — pip install pytest-azurepipelines · libregistry