Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/requirements.py: remove the test_wrapper functions #285

Merged
merged 1 commit into from
Jun 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 33 additions & 23 deletions tests/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,11 @@
#
# SPDX-License-Identifier: MIT

import pytest


def mark_requirement(requirement):
def wrapper(test_func):
@pytest.mark.components(DatumaroComponent.Datumaro)
@pytest.mark.component
@pytest.mark.priority_medium
@pytest.mark.reqids(requirement)
def test_wrapper(*args, **kwargs):
return test_func(*args, **kwargs)
return test_wrapper
return wrapper
import typing

def mark_bug(bugs):
def wrapper(test_func):
@pytest.mark.components(DatumaroComponent.Datumaro)
@pytest.mark.component
@pytest.mark.priority_medium
@pytest.mark.bugs(bugs)
def test_wrapper(*args, **kwargs):
return test_func(*args, **kwargs)
return test_wrapper
return wrapper
from attr import attrs

import pytest

class DatumaroComponent:
Datumaro = "datumaro"
Expand All @@ -47,3 +27,33 @@ class Requirements:

class SkipMessages:
NOT_IMPLEMENTED = "NOT IMPLEMENTED"


@attrs(auto_attribs=True)
class _CombinedDecorator:
decorators: typing.List[typing.Callable]

def __call__(self, function):
for d in reversed(self.decorators):
function = d(function)

return function


_SHARED_DECORATORS = [
pytest.mark.components(DatumaroComponent.Datumaro),
pytest.mark.component,
pytest.mark.priority_medium,
]

def mark_requirement(requirement):
return _CombinedDecorator([
*_SHARED_DECORATORS,
pytest.mark.reqids(requirement),
])

def mark_bug(bugs):
return _CombinedDecorator([
*_SHARED_DECORATORS,
pytest.mark.bugs(bugs),
])