Add decorator function which allows test functions to be wrapped
such that if they create a stack (and it is stored in the testcase
class as self.stack) it is always deleted on test exit, regardless
of test success/failure
Change-Id: Ibde9a2cee08448e3f24c6b7efbfe756a01f9eccc
Signed-off-by: Steven Hardy <shardy@redhat.com>
_skipper.__name__ = func.__name__
_skipper.__doc__ = func.__doc__
return _skipper
+
+
+def stack_delete_after(test_fn):
+ """
+ Decorator which calls test class self.stack.delete()
+ to ensure tests clean up their stacks regardless of test success/failure
+ """
+ def wrapped_test(test_cls):
+ print "Running test", test_fn.__name__
+ try:
+ test_fn(test_cls)
+ finally:
+ test_cls.stack.delete()
+ print "Exited", test_fn.__name__
+ return wrapped_test