Skip to content

Commit

Permalink
tests/requirements.py: remove the test_wrapper functions (cvat-ai#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Donchenko authored Jun 8, 2021
1 parent bda41dd commit 90e5250
Showing 1 changed file with 33 additions and 23 deletions.
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),
])

0 comments on commit 90e5250

Please sign in to comment.