Add generic nose/testtools attr decorator
Adds support for a tempest specific attr decorator which calls
the nose.plugsin.attrib attr decorator as well as the
testtools.testcase attr decorator if it is type='smoke'.
This will allow us to more smoothly transition to testtools attr
support without losing any nose functionality and preserve use of
attributes such as positive/negative/whitebox etc indefinitely.
Change-Id: Ib1ca7b5ed313b7dda55e68357f21186368df0ce6
diff --git a/tempest/test.py b/tempest/test.py
index 7804e12..58fadeb 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -18,6 +18,7 @@
import logging
import time
+import nose.plugins.attrib
import testtools
from tempest import manager
@@ -25,6 +26,25 @@
LOG = logging.getLogger(__name__)
+def attr(*args, **kwargs):
+ """A decorator which applies the nose and testtools attr decorator
+
+ This decorator applies the nose attr decorator as well as the
+ the testtools.testcase.attr if it is in the list of attributes
+ to testtools we want to apply."""
+
+ def decorator(f):
+ testtool_attributes = ('smoke')
+
+ if 'type' in kwargs and kwargs['type'] in testtool_attributes:
+ return nose.plugins.attrib.attr(*args, **kwargs)(
+ testtools.testcase.attr(kwargs['type'])(f))
+ else:
+ return nose.plugins.attrib.attr(*args, **kwargs)(f)
+
+ return decorator
+
+
class TestCase(testtools.TestCase):
"""