diff --git a/releasenotes/notes/remove-deprecated-skip_unless_attr-decorator-02bde59a00328f5c.yaml b/releasenotes/notes/remove-deprecated-skip_unless_attr-decorator-02bde59a00328f5c.yaml new file mode 100644 index 0000000000..621731d4ed --- /dev/null +++ b/releasenotes/notes/remove-deprecated-skip_unless_attr-decorator-02bde59a00328f5c.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - | + Remove the deprecated decorator ``skip_unless_attr`` in lib/decorators.py. diff --git a/tempest/lib/decorators.py b/tempest/lib/decorators.py index acbb7be030..e99dd24e6c 100644 --- a/tempest/lib/decorators.py +++ b/tempest/lib/decorators.py @@ -15,7 +15,6 @@ import functools import uuid -import debtcollector.removals from oslo_log import log as logging import six import testtools @@ -87,25 +86,6 @@ def idempotent_id(id): return decorator -@debtcollector.removals.remove(removal_version='Queen') -class skip_unless_attr(object): - """Decorator to skip tests if a specified attr does not exists or False""" - def __init__(self, attr, msg=None): - self.attr = attr - self.message = msg or ("Test case attribute %s not found " - "or False") % attr - - def __call__(self, func): - @functools.wraps(func) - def _skipper(*args, **kw): - """Wrapped skipper function.""" - testobj = args[0] - if not getattr(testobj, self.attr, False): - raise testtools.TestCase.skipException(self.message) - func(*args, **kw) - return _skipper - - def attr(**kwargs): """A decorator which applies the testtools attr decorator diff --git a/tempest/tests/lib/test_decorators.py b/tempest/tests/lib/test_decorators.py index bbebcd3b2f..ed0eea348d 100644 --- a/tempest/tests/lib/test_decorators.py +++ b/tempest/tests/lib/test_decorators.py @@ -125,35 +125,6 @@ class TestIdempotentIdDecorator(base.TestCase): self.assertRaises(ValueError, self._test_helper, _id) -class TestSkipUnlessAttrDecorator(base.TestCase): - def _test_skip_unless_attr(self, attr, expected_to_skip=True): - class TestFoo(test.BaseTestCase): - expected_attr = not expected_to_skip - - @decorators.skip_unless_attr(attr) - def test_foo(self): - pass - - t = TestFoo('test_foo') - if expected_to_skip: - self.assertRaises(testtools.TestCase.skipException, - t.test_foo) - else: - try: - t.test_foo() - except Exception: - raise testtools.TestCase.failureException() - - def test_skip_attr_does_not_exist(self): - self._test_skip_unless_attr('unexpected_attr') - - def test_skip_attr_false(self): - self._test_skip_unless_attr('expected_attr') - - def test_no_skip_for_attr_exist_and_true(self): - self._test_skip_unless_attr('expected_attr', expected_to_skip=False) - - class TestRelatedBugDecorator(base.TestCase): def test_relatedbug_when_no_exception(self): f = mock.Mock()