diff --git a/utils/_decorators.py b/utils/_decorators.py index b80d407518..dbbf822614 100644 --- a/utils/_decorators.py +++ b/utils/_decorators.py @@ -50,12 +50,12 @@ def _ensure_jira_ticket_as_reason(item, reason: str): pytest.exit(f"Please set a jira ticket for {nodeid}, instead of reason: {reason}", 1) -def _get_expected_failure_item(item, skip_reason, noxfail): +def _get_expected_failure_item(item, skip_reason, skip_test): if inspect.isfunction(item) or inspect.isclass(item): if not hasattr(item, "pytestmark"): setattr(item, "pytestmark", []) - if noxfail: + if skip_test: item.pytestmark.append(pytest.mark.skip(reason=skip_reason)) else: item.pytestmark.append(pytest.mark.xfail(reason=skip_reason)) @@ -65,7 +65,7 @@ def _get_expected_failure_item(item, skip_reason, noxfail): return item -def _should_skip(condition=None, library=None, weblog_variant=None): +def _expected_to_fail(condition=None, library=None, weblog_variant=None): if condition is False: return False @@ -94,7 +94,7 @@ def _should_skip(condition=None, library=None, weblog_variant=None): return True -def decorator(skip, noxfail, condition, decorator_type, reason, function_or_class): +def decorator(expected_to_fail, skip_test, condition, decorator_type, reason, function_or_class): if inspect.isclass(function_or_class): assert condition is not None, _MANIFEST_ERROR_MESSAGE @@ -102,29 +102,29 @@ def decorator(skip, noxfail, condition, decorator_type, reason, function_or_clas _ensure_jira_ticket_as_reason(function_or_class, reason) full_reason = decorator_type if reason is None else f"{decorator_type} ({reason})" - if not skip: + if not expected_to_fail: return function_or_class - return _get_expected_failure_item(function_or_class, full_reason, noxfail) + return _get_expected_failure_item(function_or_class, full_reason, skip_test) def missing_feature(condition=None, library=None, weblog_variant=None, reason=None, force_skip: bool = False): """decorator, allow to mark a test function/class as missing""" - skip = _should_skip(library=library, weblog_variant=weblog_variant, condition=condition) - return partial(decorator, skip, force_skip, condition, "missing_feature", reason) + expected_to_fail = _expected_to_fail(library=library, weblog_variant=weblog_variant, condition=condition) + return partial(decorator, expected_to_fail, force_skip, condition, "missing_feature", reason) def incomplete_test_app(condition=None, library=None, weblog_variant=None, reason=None): """Decorator, allow to mark a test function/class as not compatible with the tested application""" - skip = _should_skip(library=library, weblog_variant=weblog_variant, condition=condition) - noxfail = False - return partial(decorator, skip, noxfail, condition, "incomplete_test_app", reason) + expected_to_fail = _expected_to_fail(library=library, weblog_variant=weblog_variant, condition=condition) + skip_test = False + return partial(decorator, expected_to_fail, skip_test, condition, "incomplete_test_app", reason) def irrelevant(condition=None, library=None, weblog_variant=None, reason=None): """decorator, allow to mark a test function/class as not relevant""" - skip = _should_skip(library=library, weblog_variant=weblog_variant, condition=condition) - noxfail = True - return partial(decorator, skip, noxfail, condition, "irrelevant", reason) + expected_to_fail = _expected_to_fail(library=library, weblog_variant=weblog_variant, condition=condition) + skip_test = True + return partial(decorator, expected_to_fail, skip_test, condition, "irrelevant", reason) def bug(condition=None, library=None, weblog_variant=None, reason=None, force_skip: bool = False): @@ -132,17 +132,15 @@ def bug(condition=None, library=None, weblog_variant=None, reason=None, force_sk Decorator, allow to mark a test function/class as an known bug. The test is executed, and if it passes, and warning is reported """ - - expected_to_fail = _should_skip(library=library, weblog_variant=weblog_variant, condition=condition) + expected_to_fail = _expected_to_fail(library=library, weblog_variant=weblog_variant, condition=condition) return partial(decorator, expected_to_fail, force_skip, condition, "bug", reason) def flaky(condition=None, library=None, weblog_variant=None, reason=None): """Decorator, allow to mark a test function/class as a known bug, and skip it""" - - skip = _should_skip(library=library, weblog_variant=weblog_variant, condition=condition) - noxfail = True - return partial(decorator, skip, noxfail, condition, "flaky", reason) + expected_to_fail = _expected_to_fail(library=library, weblog_variant=weblog_variant, condition=condition) + skip_test = True + return partial(decorator, expected_to_fail, skip_test, condition, "flaky", reason) def released( @@ -223,16 +221,16 @@ def compute_declaration(only_for_library, component_name, declaration, tested_ve for reason in skip_reasons: if reason.startswith("flaky"): _ensure_jira_ticket_as_reason(test_class, reason[7:-1]) - return _get_expected_failure_item(test_class, reason, noxfail=True) + return _get_expected_failure_item(test_class, reason, skip_test=True) if reason.startswith("irrelevant"): - return _get_expected_failure_item(test_class, reason, noxfail=True) + return _get_expected_failure_item(test_class, reason, skip_test=True) # Otherwise, it's either bug, or missing_feature. Take the first one if reason.startswith("bug"): _ensure_jira_ticket_as_reason(test_class, reason[5:-1]) - return _get_expected_failure_item(test_class, reason, noxfail=False) + return _get_expected_failure_item(test_class, reason, skip_test=False) return test_class