提交 cfa71d00 编写于 作者: C Cleber Rosa

avocado/core/test.py: allow a test to skip itself during setUp()

It was previously not possible for a test to skip itself (due to say,
missing requirements) during the setUp() phase. Any exception caught
at this point was reflected as a test failure.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 62a54b3e
......@@ -360,6 +360,9 @@ class Test(unittest.TestCase):
stderr_check_exception = None
try:
self.setUp()
except exceptions.TestNAError, details:
stacktrace.log_exc_info(sys.exc_info(), logger='avocado.test')
raise exceptions.TestNAError(details)
except Exception, details:
stacktrace.log_exc_info(sys.exc_info(), logger='avocado.test')
raise exceptions.TestSetupFail(details)
......
#!/usr/bin/python
from avocado import Test
from avocado import main
class SkipOnSetupTest(Test):
"""
Example test that skips the current test, on the setUp phase.
"""
def setUp(self):
"""
This should end with SKIP.
"""
self.skip('This should end with SKIP.')
if __name__ == "__main__":
main()
......@@ -491,6 +491,9 @@ class PluginsXunitTest(PluginsTest):
def test_xunit_plugin_skiptest(self):
self.run_and_check('skiptest', 0, 1, 0, 0, 0, 1)
def test_xunit_plugin_skiponsetuptest(self):
self.run_and_check('skiponsetup', 0, 1, 0, 0, 0, 1)
def test_xunit_plugin_errortest(self):
self.run_and_check('errortest', 1, 1, 1, 0, 0, 0)
......@@ -549,6 +552,9 @@ class PluginsJSONTest(PluginsTest):
def test_json_plugin_skiptest(self):
self.run_and_check('skiptest', 0, 1, 0, 0, 1)
def test_json_plugin_skiponsetuptest(self):
self.run_and_check('skiponsetup', 0, 1, 0, 0, 1)
def test_json_plugin_errortest(self):
self.run_and_check('errortest', 1, 1, 1, 0, 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册