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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 33.6MB
glibcpy 3.10–3.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.fixUpgrade `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.fixUpgrade 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.fixInstall `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.fixPrepend `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.fixWhile 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.
fixpip 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.
fixExecute 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.
fixEnsure `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.
fixEnsure 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.