From fe346400f92e547ba06f4d327c53f8648c780218 Mon Sep 17 00:00:00 2001 From: andrejs Date: Wed, 18 Nov 2026 10:17:51 +0000 Subject: [PATCH 1/3] Support skipping muted tests across adapters --- README.md | 44 +++++++++++++ allure-behave/src/formatter.py | 9 ++- allure-behave/src/listener.py | 6 +- allure-nose2/src/plugin.py | 29 ++++++++- allure-nose2/src/utils.py | 1 + allure-pytest-bdd/src/plugin.py | 18 ++++++ allure-pytest-bdd/src/pytest_bdd_listener.py | 6 +- allure-pytest/src/listener.py | 4 ++ allure-pytest/src/plugin.py | 10 +++ .../src/allure_commons/model2.py | 1 + .../src/allure_commons/utils.py | 26 ++++++-- .../src/listener/allure_listener.py | 4 ++ .../src/listener/robot_listener.py | 13 +++- .../allure_api/testplan/muted_test.py | 43 +++++++++++++ .../acceptance/allure_api/muted_test.py | 62 +++++++++++++++++++ .../nose2_support/with_mp/muted_test.py | 35 +++++++++++ tests/allure_nose2/nose2_runner.py | 4 +- .../acceptance/testplan/muted_test.py | 53 ++++++++++++++++ .../pytest_xdist/pytest_xdist_select_test.py | 20 ++++++ .../acceptance/muted_test.py | 56 +++++++++++++++++ .../allure_api/testplan/muted_test.py | 31 ++++++++++ tests/conftest.py | 9 +++ tests/e2e.py | 2 + tests/testplan_test.py | 58 +++++++++++++++++ 24 files changed, 529 insertions(+), 15 deletions(-) create mode 100644 tests/allure_behave/acceptance/allure_api/testplan/muted_test.py create mode 100644 tests/allure_nose2/acceptance/allure_api/muted_test.py create mode 100644 tests/allure_nose2/acceptance/nose2_support/with_mp/muted_test.py create mode 100644 tests/allure_pytest/acceptance/testplan/muted_test.py create mode 100644 tests/allure_pytest_bdd/acceptance/muted_test.py create mode 100644 tests/allure_robotframework/acceptance/allure_api/testplan/muted_test.py create mode 100644 tests/testplan_test.py diff --git a/README.md b/README.md index 47e3454a..b59d28ef 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,50 @@ pytest plugin and distributed via Status](https://img.shields.io/pypi/v/allure-nose2)](https://pypi.python.org/pypi/allure-nose2) [![Downloads](https://img.shields.io/pypi/dm/allure-nose2)](https://pypi.python.org/pypi/allure-nose2) +## Skipping muted tests + +All adapters support `mutedTests` in the JSON test plan supplied through +`ALLURE_TESTPLAN_PATH`: + +```json +{ + "version": "1.0", + "mutedTests": [ + { "id": 101 }, + { "selector": "test_checkout#test_expired_card" } + ] +} +``` + +A matching test is skipped before its body runs and, when reporting is enabled, +retained with `status: "skipped"` and `statusDetails.muted: true`. Existing +runner filters and test-plan selection still apply: muting never adds tests to +the run. Omitting `tests`, or using `"tests": []`, leaves selection unrestricted +under the adapter’s existing rules. pytest-bdd and nose2 do not add test-plan +selection; they apply muting to the tests selected by their runners. + +IDs match static Allure ID annotations/tags, with numeric and string IDs treated +alike. IDs assigned dynamically inside a test body cannot be used for skipping. +Selectors match the adapter’s existing `fullName` exactly (not as a regex): + +| Adapter | Selector | +| --- | --- | +| pytest | `module#test`, or `module.Class#test` | +| Behave | `Feature name: Scenario name` | +| Robot Framework | `Suite.Test name` | +| pytest-bdd | `:Scenario name` | +| nose2 | `module.test`, or `module.Class.test` | + +An entry matches by ID **or** selector; an unmatched ID does not prevent a +selector match. Parameterized tests and scenario outlines keep their existing +identities, so one selector may skip multiple cases. Use the reported `fullName` +for the exact selector, including framework-specific paths and rendered names. + +Skipping uses each runner’s lifecycle. Discovery, suite setup and other hooks +may still run. Robot Framework uses its native `robot:skip` tag (Robot Framework +4+), and works with the listener alone or the existing test-plan prerun modifier. +Behave’s existing skipped-result visibility options still apply. + ## Allure python commons Common engine for all modules. It is useful for make integration with diff --git a/allure-behave/src/formatter.py b/allure-behave/src/formatter.py index fd5576f1..1061e71e 100644 --- a/allure-behave/src/formatter.py +++ b/allure-behave/src/formatter.py @@ -4,7 +4,9 @@ from allure_commons.logger import AllureFileLogger from allure_behave.listener import AllureListener from allure_commons.utils import get_testplan -from allure_behave.utils import is_planned_scenario +from allure_behave.utils import is_planned_scenario, get_fullname, scenario_labels, TEST_PLAN_SKIP_REASON +from allure_commons.utils import matches_testplan, MUTED_TEST_REASON +from allure_commons.types import LabelType class AllureFormatter(Formatter): @@ -18,6 +20,7 @@ def __init__(self, stream_opener, config): allure_commons.plugin_manager.register(self.file_logger) self.testplan = get_testplan() + self.muted_tests = get_testplan("mutedTests") def _wrap_scenario(self, scenarios): for scenario in scenarios: @@ -26,6 +29,10 @@ def _wrap_scenario(self, scenarios): else: scenario.run = allure_commons.test(scenario.run, context={"scenario": scenario}) is_planned_scenario(scenario, self.testplan) + if not isinstance(scenario, ScenarioOutline) and scenario.skip_reason != TEST_PLAN_SKIP_REASON: + ids = [label.value for label in scenario_labels(scenario) if label.name == LabelType.ID] + if matches_testplan(self.muted_tests, allure_ids=ids, selector=get_fullname(scenario)): + scenario.skip(reason=MUTED_TEST_REASON) def uri(self, uri): self.listener.start_file() diff --git a/allure-behave/src/listener.py b/allure-behave/src/listener.py index 322a23c6..9600f26e 100644 --- a/allure-behave/src/listener.py +++ b/allure-behave/src/listener.py @@ -6,7 +6,8 @@ from allure_commons.utils import now from allure_commons.utils import platform_label from allure_commons.types import LabelType, AttachmentType, LinkType -from allure_commons.model2 import TestResult +from allure_commons.model2 import TestResult, Status, StatusDetails +from allure_commons.utils import MUTED_TEST_REASON from allure_commons.model2 import TestStepResult from allure_commons.model2 import TestBeforeResult, TestAfterResult from allure_commons.model2 import TestResultContainer @@ -112,6 +113,9 @@ def stop_scenario(self, scenario): else: status = scenario_status(scenario) status_details = scenario_status_details(scenario) + if scenario.skip_reason == MUTED_TEST_REASON: + status = Status.SKIPPED + status_details = StatusDetails(message=MUTED_TEST_REASON, muted=True) self.flush_steps() test_result = self.logger.get_test(self.current_scenario_uuid) diff --git a/allure-nose2/src/plugin.py b/allure-nose2/src/plugin.py index edd4d65d..a18d1c31 100644 --- a/allure-nose2/src/plugin.py +++ b/allure-nose2/src/plugin.py @@ -1,3 +1,5 @@ +from unittest import skip + from nose2.events import Plugin from allure_commons import plugin_manager from allure_commons.logger import AllureFileLogger @@ -8,7 +10,8 @@ from allure_commons.model2 import StatusDetails from allure_commons.model2 import Label from allure_commons.types import LabelType -from allure_commons.utils import host_tag, thread_tag +from allure_commons.utils import host_tag, thread_tag, get_testplan +from allure_commons.utils import matches_testplan, MUTED_TEST_REASON from allure_commons.utils import platform_label, md5 @@ -54,6 +57,7 @@ def __init__(self, *args, **kwargs): self.lifecycle = AllureLifecycle() self.logger = AllureFileLogger("allure-result") self.listener = AllureListener(self.lifecycle) + self._muted_tests = {} def registerInSubprocess(self, event): self.unregister_allure_plugins() @@ -70,8 +74,9 @@ def register_allure_plugins(self): plugin_manager.register(self.logger) def unregister_allure_plugins(self): - plugin_manager.unregister(plugin=self.listener) - plugin_manager.unregister(plugin=self.logger) + for plugin in (self.listener, self.logger): + if plugin_manager.is_registered(plugin): + plugin_manager.unregister(plugin=plugin) def is_registered(self): return all([plugin_manager.is_registered(self.listener), @@ -99,11 +104,26 @@ def startTest(self, event): test_result.labels.append(Label(name=LabelType.LANGUAGE, value=platform_label())) test_result.parameters = params(event) + if matches_testplan( + get_testplan("mutedTests"), + allure_ids=(label.value for label in labels(event.test) if label.name == LabelType.ID), + selector=fullname(event), + ): + method_name = event.test._testMethodName + self._muted_tests[event.test] = (method_name, event.test.__dict__.get(method_name)) + setattr(event.test, method_name, skip(MUTED_TEST_REASON)(lambda: None)) + def stopTest(self, event): if self.is_registered(): with self.lifecycle.update_test_case() as test_result: test_result.stop = timestamp_millis(event.stopTime) self.lifecycle.write_test_case() + if event.test in self._muted_tests: + method_name, original = self._muted_tests.pop(event.test) + if original is None: + delattr(event.test, method_name) + else: + setattr(event.test, method_name, original) def testOutcome(self, event): if self.is_registered(): @@ -122,6 +142,9 @@ def testOutcome(self, event): elif event.outcome == result.SKIP: test_result.status = Status.SKIPPED test_result.statusDetails = status_details(event) + if event.test in self._muted_tests: + test_result.statusDetails = test_result.statusDetails or StatusDetails() + test_result.statusDetails.muted = True # Todo default status and other cases # elif event.outcome == result.FAIL and event.expected: # pass diff --git a/allure-nose2/src/utils.py b/allure-nose2/src/utils.py index 23e83d23..26953dc3 100644 --- a/allure-nose2/src/utils.py +++ b/allure-nose2/src/utils.py @@ -10,6 +10,7 @@ "epic", "feature", "story", + "as_id", ] diff --git a/allure-pytest-bdd/src/plugin.py b/allure-pytest-bdd/src/plugin.py index 378a9177..8a6f9650 100644 --- a/allure-pytest-bdd/src/plugin.py +++ b/allure-pytest-bdd/src/plugin.py @@ -1,5 +1,11 @@ import argparse import os +import pytest + +from allure_commons.utils import get_testplan +from allure_commons.utils import matches_testplan, MUTED_TEST_REASON +from allure_commons.types import LabelType +from .utils import iter_label_values, get_full_name import allure_commons from allure_commons.logger import AllureFileLogger @@ -71,6 +77,18 @@ def register_marks(config): config.addinivalue_line("markers", f"{ALLURE_EXPECTED_RESULTS_HTML_MARK}: allure expected results html") +@pytest.hookimpl(trylast=True) +def pytest_bdd_before_scenario(request, feature, scenario): + item = request.node + item._allure_muted = matches_testplan( + get_testplan("mutedTests"), + allure_ids=(value for _, value in iter_label_values(item, LabelType.ID)), + selector=get_full_name(feature, scenario), + ) + if item._allure_muted: + pytest.skip(MUTED_TEST_REASON) + + def pytest_configure(config): register_marks(config) diff --git a/allure-pytest-bdd/src/pytest_bdd_listener.py b/allure-pytest-bdd/src/pytest_bdd_listener.py index 6d406129..381f3255 100644 --- a/allure-pytest-bdd/src/pytest_bdd_listener.py +++ b/allure-pytest-bdd/src/pytest_bdd_listener.py @@ -4,7 +4,7 @@ from allure_commons.utils import now from allure_commons.model2 import Label -from allure_commons.model2 import Status +from allure_commons.model2 import Status, StatusDetails from allure_commons.types import LabelType, AttachmentType from allure_commons.utils import platform_label from allure_commons.utils import host_tag, thread_tag @@ -153,6 +153,10 @@ def pytest_runtest_makereport(self, item, call): attach_data(self.lifecycle, report.capstdout, "stdout", AttachmentType.TEXT, None) if report.capstderr: attach_data(self.lifecycle, report.capstderr, "stderr", AttachmentType.TEXT, None) + if getattr(item, "_allure_muted", False): + test_result.stop = test_result.stop or now() + test_result.statusDetails = test_result.statusDetails or StatusDetails() + test_result.statusDetails.muted = True post_process_test_result(item, test_result) if report.when == "teardown": diff --git a/allure-pytest/src/listener.py b/allure-pytest/src/listener.py index 6ab235db..c7a7d6f1 100644 --- a/allure-pytest/src/listener.py +++ b/allure-pytest/src/listener.py @@ -228,6 +228,10 @@ def pytest_runtest_makereport(self, item, call): message = f"XPASS {reason}" if reason else "XPASS" status_details = StatusDetails(message=message) + if getattr(item, "_allure_muted", False): + status_details = status_details or StatusDetails() + status_details.muted = True + if report.when == "setup": test_result.status = status test_result.statusDetails = status_details diff --git a/allure-pytest/src/plugin.py b/allure-pytest/src/plugin.py index 1eedfada..fc946296 100644 --- a/allure-pytest/src/plugin.py +++ b/allure-pytest/src/plugin.py @@ -1,4 +1,5 @@ import argparse +import pytest import allure import allure_commons @@ -7,6 +8,7 @@ from allure_commons.types import LabelType, Severity from allure_commons.logger import AllureFileLogger from allure_commons.utils import get_testplan +from allure_commons.utils import matches_testplan, MUTED_TEST_REASON from allure_pytest.utils import allure_label, allure_labels, allure_full_name from allure_pytest.helper import AllureTestHelper, AllureTitleHelper @@ -240,6 +242,14 @@ def pytest_collection_modifyitems(items, config): selected, deselected_by_testcase = select_by_testcase(items, config) selected, deselected_by_labels = select_by_labels(selected, config) + muted_tests = get_testplan("mutedTests") + for item in selected: + item._allure_muted = matches_testplan( + muted_tests, allure_ids=allure_label(item, LabelType.ID), selector=allure_full_name(item) + ) + if item._allure_muted: + item.add_marker(pytest.mark.skip(reason=MUTED_TEST_REASON)) + items[:] = selected if deselected_by_testcase or deselected_by_labels: diff --git a/allure-python-commons/src/allure_commons/model2.py b/allure-python-commons/src/allure_commons/model2.py index 9a7fa72b..8c43553a 100644 --- a/allure-python-commons/src/allure_commons/model2.py +++ b/allure-python-commons/src/allure_commons/model2.py @@ -100,6 +100,7 @@ class StatusDetails: flaky = attrib(default=None) message = attrib(default=None) trace = attrib(default=None) + muted = attrib(default=None) @attrs diff --git a/allure-python-commons/src/allure_commons/utils.py b/allure-python-commons/src/allure_commons/utils.py index c50cb7ec..df5e2358 100644 --- a/allure-python-commons/src/allure_commons/utils.py +++ b/allure-python-commons/src/allure_commons/utils.py @@ -12,9 +12,13 @@ import traceback import collections +from functools import lru_cache from traceback import format_exception_only +MUTED_TEST_REASON = "Skipped by Allure test plan" + + def md5(*args): m = hashlib.md5() for arg in args: @@ -323,16 +327,26 @@ def format_exception(etype, value): return "\n".join(format_exception_only(etype, value)) if etype or value else None -def get_testplan(): - planned_tests = [] +@lru_cache(maxsize=1) +def _load_testplan(): file_path = os.environ.get("ALLURE_TESTPLAN_PATH") - if file_path and os.path.exists(file_path): with open(file_path, "r") as plan_file: - plan = json.load(plan_file) - planned_tests = plan.get("tests", []) + return json.load(plan_file) + return {} + - return planned_tests +def get_testplan(field="tests"): + return _load_testplan().get(field, []) + + +def matches_testplan(entries, allure_ids=(), selector=None): + ids = {str(value) for value in allure_ids if value is not None} + return any( + (entry.get("id") is not None and str(entry["id"]) in ids) + or (selector is not None and entry.get("selector") == selector) + for entry in entries or [] + ) class SafeFormatter(string.Formatter): diff --git a/allure-robotframework/src/listener/allure_listener.py b/allure-robotframework/src/listener/allure_listener.py index 7219baca..27f48cdd 100644 --- a/allure-robotframework/src/listener/allure_listener.py +++ b/allure-robotframework/src/listener/allure_listener.py @@ -12,6 +12,7 @@ from allure_commons.utils import format_exception, format_traceback from allure_commons.model2 import Label, Link from allure_commons.model2 import Status, StatusDetails +from allure_commons.utils import MUTED_TEST_REASON from allure_commons.model2 import Parameter from allure_commons.types import LabelType, AttachmentType, Severity, LinkType from allure_robotframework.utils import get_allure_status @@ -158,6 +159,9 @@ def stop_test(self, _, attributes, messages): test_result.labels.extend(allure_labels(tags)) test_result.statusDetails = StatusDetails(message=attributes.get("message"), trace=self._current_tb) + if attributes.get("allure_muted"): + test_result.status = Status.SKIPPED + test_result.statusDetails = StatusDetails(message=MUTED_TEST_REASON, muted=True) if attributes.get("critical") == "yes": test_result.labels.append(Label(name=LabelType.SEVERITY, value=Severity.CRITICAL)) diff --git a/allure-robotframework/src/listener/robot_listener.py b/allure-robotframework/src/listener/robot_listener.py index acc0624c..f398a112 100644 --- a/allure-robotframework/src/listener/robot_listener.py +++ b/allure-robotframework/src/listener/robot_listener.py @@ -1,5 +1,10 @@ import os import allure_commons +from robot.libraries.BuiltIn import BuiltIn +from allure_commons.utils import get_testplan +from allure_commons.utils import matches_testplan +from allure_commons.types import LabelType +from allure_robotframework.utils import allure_labels from allure_commons.lifecycle import AllureLifecycle from allure_commons.logger import AllureFileLogger @@ -17,6 +22,8 @@ class allure_robotframework: def __init__(self, logger_path=DEFAULT_OUTPUT_PATH): self.messages = Messages() self.title_path = [] + self.muted_tests = get_testplan("mutedTests") + self._muted = False self.logger = AllureFileLogger(logger_path) self.lifecycle = AllureLifecycle() @@ -37,12 +44,16 @@ def end_suite(self, name, attributes): def start_test(self, name, attributes): self.messages.start_context() + ids = [label.value for label in allure_labels(attributes.get("tags", ())) if label.name == LabelType.ID] + self._muted = matches_testplan(self.muted_tests, allure_ids=ids, selector=attributes.get("longname")) + if self._muted: + BuiltIn().set_tags("robot:skip") self.listener.start_test_container(name, attributes) self.listener.start_test(name, {**attributes, "titlepath": self.title_path}) def end_test(self, name, attributes): messages = self.messages.stop_context() - self.listener.stop_test(name, attributes, messages) + self.listener.stop_test(name, {**attributes, "allure_muted": self._muted}, messages) self.listener.stop_test_container(name, attributes) def start_keyword(self, name, attributes): diff --git a/tests/allure_behave/acceptance/allure_api/testplan/muted_test.py b/tests/allure_behave/acceptance/allure_api/testplan/muted_test.py new file mode 100644 index 00000000..57efb9d7 --- /dev/null +++ b/tests/allure_behave/acceptance/allure_api/testplan/muted_test.py @@ -0,0 +1,43 @@ +import pytest + + +@pytest.mark.parametrize("entry", [{"id": 12}, {"id": "unknown", "selector": "Muting: Muted scenario"}]) +@pytest.mark.parametrize("selected", [False, True]) +def test_muted_scenarios(behave_runner, entry, selected): + plan = {"mutedTests": [entry, {"selector": "Muting: Outside"}]} + if selected: + plan["tests"] = [{"selector": "Muting: Muted scenario"}, {"selector": "Muting: Active"}] + + results = behave_runner.run_behave( + feature_literals=[""" +Feature: Muting + @allure.id:12 + Scenario Outline: Muted scenario + Given forbidden + Examples: + | value | + | one | + | two | + Scenario: Active + Given allowed + Scenario: Outside + Given forbidden outside +"""], + step_literals=[""" +from behave import given +@given('forbidden {value}') +def forbidden(context, value): + raise AssertionError('muted step ran') +@given('allowed') +def allowed(context): + pass +"""], + testplan_content=plan, + options=["-D", "AllureFormatter.hide_excluded=True"] + ) + + muted = [result for result in results.test_cases if result["name"].startswith("Muted")] + assert len(results.test_cases) == (3 if selected else 4) + assert len(muted) == 2 + assert all(result["status"] == "skipped" and result["statusDetails"]["muted"] is True for result in muted) + assert next(result for result in results.test_cases if result["name"] == "Active")["status"] == "passed" diff --git a/tests/allure_nose2/acceptance/allure_api/muted_test.py b/tests/allure_nose2/acceptance/allure_api/muted_test.py new file mode 100644 index 00000000..4ff5cd50 --- /dev/null +++ b/tests/allure_nose2/acceptance/allure_api/muted_test.py @@ -0,0 +1,62 @@ +import pytest + + +@pytest.mark.parametrize("entry", [{"id": 12}, {"id": "missing", "selector": "muting.test_muted"}]) +def test_muted_functions(nose2_runner, entry): + """ + >>> import allure + >>> from nose2.tools import params + >>> @allure.id("12") + ... @params("one", "two") + ... def test_muted(value): + ... raise AssertionError("muted body ran") + >>> def test_active(): + ... pass + """ + results = nose2_runner.run_docstring(module_name="muting", testplan={"mutedTests": [entry]}) + + muted = [result for result in results.test_cases if result["fullName"] == "muting.test_muted"] + assert len(results.test_cases) == 3 + assert len(muted) == 2 + assert all(result["status"] == "skipped" and result["statusDetails"]["muted"] for result in muted) + assert next(result for result in results.test_cases if result["name"] == "test_active")["status"] == "passed" + + +@pytest.mark.parametrize("entry", [{"id": "34"}, {"selector": "muting.TestMuted.test_muted"}]) +def test_muted_methods(nose2_runner, entry): + """ + >>> import allure + >>> from unittest import TestCase + >>> @allure.id(34) + ... class TestMuted(TestCase): + ... def setUp(self): + ... raise AssertionError("muted setup ran") + ... def test_muted(self): + ... raise AssertionError("muted body ran") + """ + results = nose2_runner.run_docstring(module_name="muting", testplan={"tests": [], "mutedTests": [entry]}) + + assert len(results.test_cases) == 1 + assert results.test_cases[0]["status"] == "skipped" + assert results.test_cases[0]["statusDetails"]["muted"] is True + + +def test_muted_parameterized_methods(nose2_runner): + """ + >>> import allure + >>> from nose2.tools import params + >>> from unittest import TestCase + >>> class TestMuted(TestCase): + ... @allure.id("56") + ... @params("one", "two") + ... def test_muted(self, value): + ... raise AssertionError("muted body ran") + ... def test_active(self): + ... pass + """ + results = nose2_runner.run_docstring(module_name="muting", testplan={"mutedTests": [{"id": 56}]}) + + muted = [result for result in results.test_cases if result["name"].startswith("test_muted")] + assert len(muted) == 2 + assert all(result["status"] == "skipped" and result["statusDetails"]["muted"] for result in muted) + assert next(result for result in results.test_cases if result["name"] == "test_active")["status"] == "passed" diff --git a/tests/allure_nose2/acceptance/nose2_support/with_mp/muted_test.py b/tests/allure_nose2/acceptance/nose2_support/with_mp/muted_test.py new file mode 100644 index 00000000..4290101e --- /dev/null +++ b/tests/allure_nose2/acceptance/nose2_support/with_mp/muted_test.py @@ -0,0 +1,35 @@ +import json +import os +from pathlib import Path +import subprocess +import sys + + +def test_muted_tests_in_subprocesses(tmp_path): + (tmp_path / "test_muting.py").write_text(""" +import allure +from unittest import TestCase +@allure.id("12") +class TestMuted(TestCase): + def test_muted(self): + raise AssertionError("muted body ran") +def test_active(): + pass +""") + plan = tmp_path / "plan.json" + plan.write_text(json.dumps({"mutedTests": [{"id": 12}]})) + + run = subprocess.run( + [sys.executable, "-m", "nose2", "--plugin", "allure_nose2.plugin", "--allure", + "--plugin", "nose2.plugins.mp", "-N2"], + cwd=tmp_path, env={**os.environ, "ALLURE_TESTPLAN_PATH": str(plan)}, + capture_output=True, text=True, + ) + results = [json.loads(path.read_text()) for path in Path(tmp_path / "allure-result").glob("*-result.json")] + + assert run.returncode == 0, run.stdout + run.stderr + assert len(results) == 2 + muted = next(result for result in results if result["name"] == "test_muted") + assert muted["status"] == "skipped" + assert muted["statusDetails"]["muted"] is True + assert next(result for result in results if result["name"] == "test_active")["status"] == "passed" diff --git a/tests/allure_nose2/nose2_runner.py b/tests/allure_nose2/nose2_runner.py index e5cf1802..81fdb0d4 100644 --- a/tests/allure_nose2/nose2_runner.py +++ b/tests/allure_nose2/nose2_runner.py @@ -12,12 +12,12 @@ class AllureNose2Runner(AllureFrameworkRunner): def __init__(self, request: FixtureRequest, pytester: Pytester): super().__init__(request, pytester, AllureNose2Runner.LOGGER_PATH) - def run_docstring(self, module_name=None): + def run_docstring(self, module_name=None, testplan=None): docstring = self._find_docstring() example_code = script_from_examples(docstring) spec = importlib.machinery.ModuleSpec(module_name or self.request.node.name, None) module = importlib.util.module_from_spec(spec) - return self._run(module, example_code) + return self._run(module, example_code, testplan_content=testplan) def _run_framework(self, module, example): # We execute the example here because the _run_framework runs in a diff --git a/tests/allure_pytest/acceptance/testplan/muted_test.py b/tests/allure_pytest/acceptance/testplan/muted_test.py new file mode 100644 index 00000000..1f10a572 --- /dev/null +++ b/tests/allure_pytest/acceptance/testplan/muted_test.py @@ -0,0 +1,53 @@ +import pytest + + +@pytest.mark.parametrize("selection", [None, []]) +@pytest.mark.parametrize("entry", [{"id": 12}, {"selector": "test_muted_sample#test_muted"}]) +def test_muted_body_is_not_run(allure_pytest_runner, entry, selection): + """ + >>> import allure + >>> import pytest + >>> @pytest.mark.parametrize("value", [1, 2]) + ... @allure.id("12") + ... def test_muted(value): + ... raise AssertionError("muted body ran") + >>> def test_active(): + ... pass + >>> @pytest.mark.skip(reason="user") + ... def test_user_skip(): + ... pass + """ + plan = {"mutedTests": [entry]} + if selection is not None: + plan["tests"] = selection + + results = allure_pytest_runner.run_docstring(filename="test_muted_sample", testplan=plan) + + muted = [result for result in results.test_cases if result["name"].startswith("test_muted")] + assert len(results.test_cases) == 4 + assert len(muted) == 2 + assert all(result["status"] == "skipped" and result["statusDetails"]["muted"] is True for result in muted) + assert next(result for result in results.test_cases if result["name"] == "test_active")["status"] == "passed" + assert not next(result for result in results.test_cases if result["name"] == "test_user_skip")[ + "statusDetails" + ].get("muted", False) + + +@pytest.mark.parametrize("inverted,expected", [(False, "test_selected"), (True, "test_outside")]) +def test_muting_does_not_change_selection(allure_pytest_runner, inverted, expected): + """ + >>> def test_selected(): + ... pass + >>> def test_outside(): + ... raise AssertionError("muted body ran") + """ + results = allure_pytest_runner.run_docstring( + *(["--inversion", "true"] if inverted else []), + filename="test_muted_sample", + testplan={"tests": [{"selector": "test_muted_sample#test_selected"}], + "mutedTests": [{"selector": "test_muted_sample#test_outside"}]} + ) + + assert len(results.test_cases) == 1 + assert results.test_cases[0]["name"] == expected + assert results.test_cases[0]["status"] == ("skipped" if inverted else "passed") diff --git a/tests/allure_pytest/externals/pytest_xdist/pytest_xdist_select_test.py b/tests/allure_pytest/externals/pytest_xdist/pytest_xdist_select_test.py index d9984fc1..56788755 100644 --- a/tests/allure_pytest/externals/pytest_xdist/pytest_xdist_select_test.py +++ b/tests/allure_pytest/externals/pytest_xdist/pytest_xdist_select_test.py @@ -13,6 +13,26 @@ def xdist_runner(allure_pytest_runner: AllurePytestRunner): yield allure_pytest_runner +def test_xdist_muted_tests(xdist_runner: AllurePytestRunner): + """ + >>> import allure + >>> import pytest + >>> @allure.id("12") + ... @pytest.mark.parametrize("value", ["one", "two"]) + ... def test_muted(value): + ... raise AssertionError("muted body ran") + >>> def test_active(): + ... pass + """ + results = xdist_runner.run_docstring("-n2", testplan={"mutedTests": [{"id": 12}]}) + + muted = [result for result in results.test_cases if result["name"].startswith("test_muted")] + assert len(results.test_cases) == 3 + assert len(muted) == 2 + assert all(result["status"] == "skipped" and result["statusDetails"]["muted"] for result in muted) + assert next(result for result in results.test_cases if result["name"] == "test_active")["status"] == "passed" + + @allure.issue("292") @allure.feature("Integration") def test_xdist_and_select_test_by_bdd_label(xdist_runner: AllurePytestRunner): diff --git a/tests/allure_pytest_bdd/acceptance/muted_test.py b/tests/allure_pytest_bdd/acceptance/muted_test.py new file mode 100644 index 00000000..c681d68d --- /dev/null +++ b/tests/allure_pytest_bdd/acceptance/muted_test.py @@ -0,0 +1,56 @@ +import os +import pytest + +from tests.e2e import version_gte + + +@pytest.mark.parametrize("entry", [{"id": 12}, {"id": "missing", "selector": "muting.feature:Muted"}]) +@pytest.mark.parametrize("selection", [None, []]) +@pytest.mark.parametrize("workers", [False, True]) +def test_muted_scenario_bodies(allure_pytest_bdd_runner, entry, selection, workers): + if workers: + allure_pytest_bdd_runner.in_memory = False + allure_pytest_bdd_runner.enable_plugins("xdist") + entry = dict(entry) + if "selector" in entry and version_gte("pytest-bdd", 8): + entry["selector"] = os.path.join(allure_pytest_bdd_runner.pytester.path.name, entry["selector"]) + plan = {"mutedTests": [entry]} + if selection is not None: + plan["tests"] = selection + results = allure_pytest_bdd_runner.run_pytest( + ("muting.feature", """ +Feature: Muting + Scenario Outline: Muted + Given forbidden + Examples: + | value | + | one | + | two | + Scenario: Active + Given allowed +"""), + """ +import allure +from pytest_bdd import scenario, given, parsers +@allure.id("12") +@scenario("muting.feature", "Muted") +def test_muted(): + pass +@scenario("muting.feature", "Active") +def test_active(): + pass +@given(parsers.parse("forbidden {value}")) +def forbidden(value): + raise AssertionError("muted step ran") +@given("allowed") +def allowed(): + pass +""", testplan=plan, cli_args=["-n2"] if workers else [] + ) + + muted = [result for result in results.test_cases if result["name"] == "Muted"] + assert len(results.test_cases) == 3 + assert len(muted) == 2 + assert all(result["status"] == "skipped" and result["statusDetails"]["muted"] is True for result in muted) + assert all(result.get("stop") and result.get("historyId") for result in muted) + assert next(result for result in results.test_cases if result["name"] == "Active")["status"] == "passed" diff --git a/tests/allure_robotframework/acceptance/allure_api/testplan/muted_test.py b/tests/allure_robotframework/acceptance/allure_api/testplan/muted_test.py new file mode 100644 index 00000000..9add67dd --- /dev/null +++ b/tests/allure_robotframework/acceptance/allure_api/testplan/muted_test.py @@ -0,0 +1,31 @@ +import pytest + + +@pytest.mark.parametrize("modifier", [False, True]) +@pytest.mark.parametrize("entry", [{"id": 12}, {"id": "unknown", "selector": "Muting.Muted"}]) +@pytest.mark.parametrize("selected", [False, True]) +def test_muted_robot_tests(robot_runner, modifier, entry, selected): + options = {"prerunmodifier": "allure_robotframework.testplan"} if modifier else {} + plan = {"mutedTests": [entry, {"selector": "Muting.Outside"}]} + if selected and modifier: + plan["tests"] = [{"selector": "Muting.Muted"}, {"selector": "Muting.Active"}] + results = robot_runner.run_robotframework( + suite_literals={"muting.robot": """ +*** Test Cases *** +Muted + [Tags] allure.id:12 + Fail muted body ran +Active + No Operation +Outside + Fail muted body ran +"""}, + testplan_content=plan, + options=options + ) + + assert len(results.test_cases) == (2 if selected and modifier else 3) + muted = next(result for result in results.test_cases if result["name"] == "Muted") + assert muted["status"] == "skipped" + assert muted["statusDetails"]["muted"] is True + assert next(result for result in results.test_cases if result["name"] == "Active")["status"] == "passed" diff --git a/tests/conftest.py b/tests/conftest.py index efd47e01..2b13b89b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,6 +5,15 @@ pytest_plugins = "pytester" +@pytest.fixture(autouse=True) +def reset_testplan_cache(): + from allure_commons.utils import _load_testplan + + _load_testplan.cache_clear() + yield + _load_testplan.cache_clear() + + @pytest.fixture def rst_examples(request: FixtureRequest) -> RstExampleTable: return RstExampleTable.find_examples(request) diff --git a/tests/e2e.py b/tests/e2e.py index 5453e6fa..63c21cc6 100644 --- a/tests/e2e.py +++ b/tests/e2e.py @@ -21,6 +21,7 @@ from typing import Tuple, Mapping, TypeVar, Generator, Callable, Union import allure_commons +from allure_commons.utils import _load_testplan from allure_commons.logger import AllureMemoryLogger from allure_commons_test.report import AllureReport @@ -433,6 +434,7 @@ def _run( rst_id=testplan_rst_id ) with altered_env(ALLURE_TESTPLAN_PATH=testplan_path): + _load_testplan.cache_clear() output = self.__run_and_collect_results_in_memory( args, kwargs diff --git a/tests/testplan_test.py b/tests/testplan_test.py new file mode 100644 index 00000000..2f9c22e6 --- /dev/null +++ b/tests/testplan_test.py @@ -0,0 +1,58 @@ +import json +from unittest.mock import patch + +import pytest + +from allure_commons.utils import get_testplan + + +@pytest.mark.parametrize("selection", [None, []]) +def test_muted_plan_loading(tmp_path, monkeypatch, selection): + plan = {"mutedTests": [{"id": 101}]} + if selection is not None: + plan["tests"] = selection + path = tmp_path / "testplan.json" + path.write_text(json.dumps(plan)) + monkeypatch.setenv("ALLURE_TESTPLAN_PATH", str(path)) + + muted = get_testplan("mutedTests") + + assert muted == [{"id": 101}] + assert get_testplan() == [] + + +def test_testplan_parsed_once_for_both_fields(tmp_path, monkeypatch): + path = tmp_path / "testplan.json" + path.write_text('{"tests": [{"id": 1}], "mutedTests": [{"id": 2}]}') + monkeypatch.setenv("ALLURE_TESTPLAN_PATH", str(path)) + + with patch("allure_commons.utils.json.load", wraps=json.load) as load: + selected = get_testplan() + muted = get_testplan("mutedTests") + repeated = get_testplan("mutedTests") + + assert selected == [{"id": 1}] + assert muted == repeated == [{"id": 2}] + assert load.call_count == 1 + + +@pytest.mark.parametrize("entries,ids,selector,expected", [ + ([{"id": 101}], ("101",), None, True), + ([{"id": "101"}], (101,), None, True), + ([{"id": "101"}], ("other", "101"), None, True), + ([{"selector": "file#test[case]"}], (), "file#test[case]", True), + ([{"selector": "file#test[case]"}], (), "file#testc", False), + ([{"selector": "file#test"}], (), "other#test", False), + ([{"id": 101, "selector": "different"}], ("101",), "file#test", True), + ([{"id": "different", "selector": "file#test"}], ("101",), "file#test", True), + ([{}], (), None, False), + ([{"id": None, "selector": None}], (None,), None, False), + ([{"id": "None"}], (), None, False), + ([], ("101",), "file#test", False), +]) +def test_matching_nonmissing_id_or_exact_selector(entries, ids, selector, expected): + from allure_commons.utils import matches_testplan + + matched = matches_testplan(entries, allure_ids=ids, selector=selector) + + assert matched is expected From 4936accfe5a164c71c3e42ddb20f67dfad7f01d0 Mon Sep 17 00:00:00 2001 From: andrejs Date: Wed, 18 Nov 2026 10:43:55 +0000 Subject: [PATCH 2/3] Install pytest-xdist for pytest-bdd tests --- requirements/testing/allure-pytest-bdd.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/testing/allure-pytest-bdd.txt b/requirements/testing/allure-pytest-bdd.txt index 19b9ce8f..ff802f20 100644 --- a/requirements/testing/allure-pytest-bdd.txt +++ b/requirements/testing/allure-pytest-bdd.txt @@ -1 +1,2 @@ # allure_pytest_bdd testing deps +pytest-xdist From 28904eacd84e0528595e067582c503399bfa519d Mon Sep 17 00:00:00 2001 From: andrejs Date: Thu, 19 Nov 2026 09:19:01 +0000 Subject: [PATCH 3/3] Update key name --- README.md | 4 ++-- allure-behave/src/formatter.py | 2 +- allure-nose2/src/plugin.py | 2 +- allure-pytest-bdd/src/plugin.py | 2 +- allure-pytest/src/plugin.py | 2 +- allure-robotframework/src/listener/robot_listener.py | 2 +- .../acceptance/allure_api/testplan/muted_test.py | 2 +- tests/allure_nose2/acceptance/allure_api/muted_test.py | 6 +++--- .../acceptance/nose2_support/with_mp/muted_test.py | 2 +- tests/allure_pytest/acceptance/testplan/muted_test.py | 4 ++-- .../externals/pytest_xdist/pytest_xdist_select_test.py | 2 +- tests/allure_pytest_bdd/acceptance/muted_test.py | 2 +- .../acceptance/allure_api/testplan/muted_test.py | 2 +- tests/testplan_test.py | 10 +++++----- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index b59d28ef..f5f0e771 100644 --- a/README.md +++ b/README.md @@ -69,13 +69,13 @@ Status](https://img.shields.io/pypi/v/allure-nose2)](https://pypi.python.org/pyp ## Skipping muted tests -All adapters support `mutedTests` in the JSON test plan supplied through +All adapters support `excludedTests` in the JSON test plan supplied through `ALLURE_TESTPLAN_PATH`: ```json { "version": "1.0", - "mutedTests": [ + "excludedTests": [ { "id": 101 }, { "selector": "test_checkout#test_expired_card" } ] diff --git a/allure-behave/src/formatter.py b/allure-behave/src/formatter.py index 1061e71e..531e44b7 100644 --- a/allure-behave/src/formatter.py +++ b/allure-behave/src/formatter.py @@ -20,7 +20,7 @@ def __init__(self, stream_opener, config): allure_commons.plugin_manager.register(self.file_logger) self.testplan = get_testplan() - self.muted_tests = get_testplan("mutedTests") + self.muted_tests = get_testplan("excludedTests") def _wrap_scenario(self, scenarios): for scenario in scenarios: diff --git a/allure-nose2/src/plugin.py b/allure-nose2/src/plugin.py index a18d1c31..baa6bf4e 100644 --- a/allure-nose2/src/plugin.py +++ b/allure-nose2/src/plugin.py @@ -105,7 +105,7 @@ def startTest(self, event): test_result.parameters = params(event) if matches_testplan( - get_testplan("mutedTests"), + get_testplan("excludedTests"), allure_ids=(label.value for label in labels(event.test) if label.name == LabelType.ID), selector=fullname(event), ): diff --git a/allure-pytest-bdd/src/plugin.py b/allure-pytest-bdd/src/plugin.py index 8a6f9650..9d18923d 100644 --- a/allure-pytest-bdd/src/plugin.py +++ b/allure-pytest-bdd/src/plugin.py @@ -81,7 +81,7 @@ def register_marks(config): def pytest_bdd_before_scenario(request, feature, scenario): item = request.node item._allure_muted = matches_testplan( - get_testplan("mutedTests"), + get_testplan("excludedTests"), allure_ids=(value for _, value in iter_label_values(item, LabelType.ID)), selector=get_full_name(feature, scenario), ) diff --git a/allure-pytest/src/plugin.py b/allure-pytest/src/plugin.py index fc946296..0318fee9 100644 --- a/allure-pytest/src/plugin.py +++ b/allure-pytest/src/plugin.py @@ -242,7 +242,7 @@ def pytest_collection_modifyitems(items, config): selected, deselected_by_testcase = select_by_testcase(items, config) selected, deselected_by_labels = select_by_labels(selected, config) - muted_tests = get_testplan("mutedTests") + muted_tests = get_testplan("excludedTests") for item in selected: item._allure_muted = matches_testplan( muted_tests, allure_ids=allure_label(item, LabelType.ID), selector=allure_full_name(item) diff --git a/allure-robotframework/src/listener/robot_listener.py b/allure-robotframework/src/listener/robot_listener.py index f398a112..669495e9 100644 --- a/allure-robotframework/src/listener/robot_listener.py +++ b/allure-robotframework/src/listener/robot_listener.py @@ -22,7 +22,7 @@ class allure_robotframework: def __init__(self, logger_path=DEFAULT_OUTPUT_PATH): self.messages = Messages() self.title_path = [] - self.muted_tests = get_testplan("mutedTests") + self.muted_tests = get_testplan("excludedTests") self._muted = False self.logger = AllureFileLogger(logger_path) diff --git a/tests/allure_behave/acceptance/allure_api/testplan/muted_test.py b/tests/allure_behave/acceptance/allure_api/testplan/muted_test.py index 57efb9d7..76be9c54 100644 --- a/tests/allure_behave/acceptance/allure_api/testplan/muted_test.py +++ b/tests/allure_behave/acceptance/allure_api/testplan/muted_test.py @@ -4,7 +4,7 @@ @pytest.mark.parametrize("entry", [{"id": 12}, {"id": "unknown", "selector": "Muting: Muted scenario"}]) @pytest.mark.parametrize("selected", [False, True]) def test_muted_scenarios(behave_runner, entry, selected): - plan = {"mutedTests": [entry, {"selector": "Muting: Outside"}]} + plan = {"excludedTests": [entry, {"selector": "Muting: Outside"}]} if selected: plan["tests"] = [{"selector": "Muting: Muted scenario"}, {"selector": "Muting: Active"}] diff --git a/tests/allure_nose2/acceptance/allure_api/muted_test.py b/tests/allure_nose2/acceptance/allure_api/muted_test.py index 4ff5cd50..3398dd43 100644 --- a/tests/allure_nose2/acceptance/allure_api/muted_test.py +++ b/tests/allure_nose2/acceptance/allure_api/muted_test.py @@ -13,7 +13,7 @@ def test_muted_functions(nose2_runner, entry): >>> def test_active(): ... pass """ - results = nose2_runner.run_docstring(module_name="muting", testplan={"mutedTests": [entry]}) + results = nose2_runner.run_docstring(module_name="muting", testplan={"excludedTests": [entry]}) muted = [result for result in results.test_cases if result["fullName"] == "muting.test_muted"] assert len(results.test_cases) == 3 @@ -34,7 +34,7 @@ def test_muted_methods(nose2_runner, entry): ... def test_muted(self): ... raise AssertionError("muted body ran") """ - results = nose2_runner.run_docstring(module_name="muting", testplan={"tests": [], "mutedTests": [entry]}) + results = nose2_runner.run_docstring(module_name="muting", testplan={"tests": [], "excludedTests": [entry]}) assert len(results.test_cases) == 1 assert results.test_cases[0]["status"] == "skipped" @@ -54,7 +54,7 @@ def test_muted_parameterized_methods(nose2_runner): ... def test_active(self): ... pass """ - results = nose2_runner.run_docstring(module_name="muting", testplan={"mutedTests": [{"id": 56}]}) + results = nose2_runner.run_docstring(module_name="muting", testplan={"excludedTests": [{"id": 56}]}) muted = [result for result in results.test_cases if result["name"].startswith("test_muted")] assert len(muted) == 2 diff --git a/tests/allure_nose2/acceptance/nose2_support/with_mp/muted_test.py b/tests/allure_nose2/acceptance/nose2_support/with_mp/muted_test.py index 4290101e..f6dc7667 100644 --- a/tests/allure_nose2/acceptance/nose2_support/with_mp/muted_test.py +++ b/tests/allure_nose2/acceptance/nose2_support/with_mp/muted_test.py @@ -17,7 +17,7 @@ def test_active(): pass """) plan = tmp_path / "plan.json" - plan.write_text(json.dumps({"mutedTests": [{"id": 12}]})) + plan.write_text(json.dumps({"excludedTests": [{"id": 12}]})) run = subprocess.run( [sys.executable, "-m", "nose2", "--plugin", "allure_nose2.plugin", "--allure", diff --git a/tests/allure_pytest/acceptance/testplan/muted_test.py b/tests/allure_pytest/acceptance/testplan/muted_test.py index 1f10a572..77de9dff 100644 --- a/tests/allure_pytest/acceptance/testplan/muted_test.py +++ b/tests/allure_pytest/acceptance/testplan/muted_test.py @@ -17,7 +17,7 @@ def test_muted_body_is_not_run(allure_pytest_runner, entry, selection): ... def test_user_skip(): ... pass """ - plan = {"mutedTests": [entry]} + plan = {"excludedTests": [entry]} if selection is not None: plan["tests"] = selection @@ -45,7 +45,7 @@ def test_muting_does_not_change_selection(allure_pytest_runner, inverted, expect *(["--inversion", "true"] if inverted else []), filename="test_muted_sample", testplan={"tests": [{"selector": "test_muted_sample#test_selected"}], - "mutedTests": [{"selector": "test_muted_sample#test_outside"}]} + "excludedTests": [{"selector": "test_muted_sample#test_outside"}]} ) assert len(results.test_cases) == 1 diff --git a/tests/allure_pytest/externals/pytest_xdist/pytest_xdist_select_test.py b/tests/allure_pytest/externals/pytest_xdist/pytest_xdist_select_test.py index 56788755..c1a35b9c 100644 --- a/tests/allure_pytest/externals/pytest_xdist/pytest_xdist_select_test.py +++ b/tests/allure_pytest/externals/pytest_xdist/pytest_xdist_select_test.py @@ -24,7 +24,7 @@ def test_xdist_muted_tests(xdist_runner: AllurePytestRunner): >>> def test_active(): ... pass """ - results = xdist_runner.run_docstring("-n2", testplan={"mutedTests": [{"id": 12}]}) + results = xdist_runner.run_docstring("-n2", testplan={"excludedTests": [{"id": 12}]}) muted = [result for result in results.test_cases if result["name"].startswith("test_muted")] assert len(results.test_cases) == 3 diff --git a/tests/allure_pytest_bdd/acceptance/muted_test.py b/tests/allure_pytest_bdd/acceptance/muted_test.py index c681d68d..e8603224 100644 --- a/tests/allure_pytest_bdd/acceptance/muted_test.py +++ b/tests/allure_pytest_bdd/acceptance/muted_test.py @@ -14,7 +14,7 @@ def test_muted_scenario_bodies(allure_pytest_bdd_runner, entry, selection, worke entry = dict(entry) if "selector" in entry and version_gte("pytest-bdd", 8): entry["selector"] = os.path.join(allure_pytest_bdd_runner.pytester.path.name, entry["selector"]) - plan = {"mutedTests": [entry]} + plan = {"excludedTests": [entry]} if selection is not None: plan["tests"] = selection results = allure_pytest_bdd_runner.run_pytest( diff --git a/tests/allure_robotframework/acceptance/allure_api/testplan/muted_test.py b/tests/allure_robotframework/acceptance/allure_api/testplan/muted_test.py index 9add67dd..f06673ef 100644 --- a/tests/allure_robotframework/acceptance/allure_api/testplan/muted_test.py +++ b/tests/allure_robotframework/acceptance/allure_api/testplan/muted_test.py @@ -6,7 +6,7 @@ @pytest.mark.parametrize("selected", [False, True]) def test_muted_robot_tests(robot_runner, modifier, entry, selected): options = {"prerunmodifier": "allure_robotframework.testplan"} if modifier else {} - plan = {"mutedTests": [entry, {"selector": "Muting.Outside"}]} + plan = {"excludedTests": [entry, {"selector": "Muting.Outside"}]} if selected and modifier: plan["tests"] = [{"selector": "Muting.Muted"}, {"selector": "Muting.Active"}] results = robot_runner.run_robotframework( diff --git a/tests/testplan_test.py b/tests/testplan_test.py index 2f9c22e6..81c05cf5 100644 --- a/tests/testplan_test.py +++ b/tests/testplan_test.py @@ -8,14 +8,14 @@ @pytest.mark.parametrize("selection", [None, []]) def test_muted_plan_loading(tmp_path, monkeypatch, selection): - plan = {"mutedTests": [{"id": 101}]} + plan = {"excludedTests": [{"id": 101}]} if selection is not None: plan["tests"] = selection path = tmp_path / "testplan.json" path.write_text(json.dumps(plan)) monkeypatch.setenv("ALLURE_TESTPLAN_PATH", str(path)) - muted = get_testplan("mutedTests") + muted = get_testplan("excludedTests") assert muted == [{"id": 101}] assert get_testplan() == [] @@ -23,13 +23,13 @@ def test_muted_plan_loading(tmp_path, monkeypatch, selection): def test_testplan_parsed_once_for_both_fields(tmp_path, monkeypatch): path = tmp_path / "testplan.json" - path.write_text('{"tests": [{"id": 1}], "mutedTests": [{"id": 2}]}') + path.write_text('{"tests": [{"id": 1}], "excludedTests": [{"id": 2}]}') monkeypatch.setenv("ALLURE_TESTPLAN_PATH", str(path)) with patch("allure_commons.utils.json.load", wraps=json.load) as load: selected = get_testplan() - muted = get_testplan("mutedTests") - repeated = get_testplan("mutedTests") + muted = get_testplan("excludedTests") + repeated = get_testplan("excludedTests") assert selected == [{"id": 1}] assert muted == repeated == [{"id": 2}]