Skip to content

Commit

Permalink
clean up variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Dec 9, 2024
1 parent 51888e0 commit 5bec54b
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions utils/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -94,55 +94,53 @@ 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, noxfail, condition, decorator_type, reason, function_or_class):
if inspect.isclass(function_or_class):
assert condition is not None, _MANIFEST_ERROR_MESSAGE

if decorator_type in ("bug", "flaky"):
_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)


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)
expected_to_fail = _expected_to_fail(library=library, weblog_variant=weblog_variant, condition=condition)
noxfail = False
return partial(decorator, skip, noxfail, condition, "incomplete_test_app", reason)
return partial(decorator, expected_to_fail, noxfail, 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)
expected_to_fail = _expected_to_fail(library=library, weblog_variant=weblog_variant, condition=condition)
noxfail = True
return partial(decorator, skip, noxfail, condition, "irrelevant", reason)
return partial(decorator, expected_to_fail, noxfail, condition, "irrelevant", reason)


def bug(condition=None, library=None, weblog_variant=None, reason=None, force_skip: bool = False):
"""
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)
expected_to_fail = _expected_to_fail(library=library, weblog_variant=weblog_variant, condition=condition)
noxfail = True
return partial(decorator, skip, noxfail, condition, "flaky", reason)
return partial(decorator, expected_to_fail, noxfail, condition, "flaky", reason)


def released(
Expand Down

0 comments on commit 5bec54b

Please sign in to comment.