Skip to main content

Generate default "unknown" results to show in Allure Report if test case does not run

Project description

allure-pytest only reports tests that were attempted

If a test case does not run (because the runner set up failed or because a CI job timed out on a previous test), the test case will be omitted from Allure Report.

This plugin creates default "unknown" status results for each test case that's expected to run. After the tests run, the default result can be included for any test case that does not have an actual test result—so that those test cases show up as "unknown" in the Allure Report.

For example, to merge the actual test results with the default "unknown" results:

import dataclasses
import json
import pathlib


@dataclasses.dataclass(frozen=True)
class Result:
    test_case_id: str
    path: pathlib.Path

    def __eq__(self, other):
        if not isinstance(other, type(self)):
            return False
        return self.test_case_id == other.test_case_id


actual_results = pathlib.Path("allure-results")
default_results = pathlib.Path("allure-default-results")

results: dict[pathlib.Path, set[Result]] = {
    actual_results: set(),
    default_results: set(),
}
for directory, results_ in results.items():
    for path in directory.glob("*-result.json"):
        with path.open("r") as file:
            id_ = json.load(file)["testCaseId"]
        results_.add(Result(id_, path))

actual_results.mkdir(exist_ok=True)

missing_results = results[default_results] - results[actual_results]
for default_result in missing_results:
    # Move to `actual_results` directory
    default_result.path.rename(actual_results / default_result.path.name)

As of 2025-01-31, the "unknown" status is not used by the allure-pytest adapter.

Upstream feature request to replace this plugin: https://github.com/allure-framework/allure-python/issues/821

Usage

Generate default results

pytest --allure-default-dir=allure-default-results

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

allure_pytest_default_results-0.1.1.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

allure_pytest_default_results-0.1.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file allure_pytest_default_results-0.1.1.tar.gz.

File metadata

File hashes

Hashes for allure_pytest_default_results-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3d67b2da3c22de08f1b1c9c1deb50c96cdadd12868466de35423c5befdcb6b08
MD5 b7c24eafd946ee5100d6d01d30e87dcb
BLAKE2b-256 1acdda900d9c7ae7827bb3e15098a5d307d2c028d34644557989157a78ed7a50

See more details on using hashes here.

Provenance

The following attestation bundles were made for allure_pytest_default_results-0.1.1.tar.gz:

Publisher: publish.yaml on canonical/allure-pytest-default-results

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file allure_pytest_default_results-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for allure_pytest_default_results-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15e16de550d446241f0e579160015e88c3e47ba3d672b1c0191cde13cf29c24c
MD5 8be173e33efb88cf24ec8ec309cebca0
BLAKE2b-256 ac82e5b9bbc760d17518d3779d3ef15b736adc512f46d37841fb63e43a937e28

See more details on using hashes here.

Provenance

The following attestation bundles were made for allure_pytest_default_results-0.1.1-py3-none-any.whl:

Publisher: publish.yaml on canonical/allure-pytest-default-results

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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