diff --git a/avocado/core/test.py b/avocado/core/test.py index fa03497a0417103a5cd13245ab58403c4e6654fb..894997c3d055990b76f5a372561d99292feb1fea 100644 --- a/avocado/core/test.py +++ b/avocado/core/test.py @@ -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) diff --git a/examples/tests/skiponsetup.py b/examples/tests/skiponsetup.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8b8e04768c76cdd89204a4621e6c9d4360cc04 --- /dev/null +++ b/examples/tests/skiponsetup.py @@ -0,0 +1,20 @@ +#!/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() diff --git a/selftests/all/functional/avocado/basic_tests.py b/selftests/all/functional/avocado/basic_tests.py index 22bb944a50c7c0f74df28de3afbe526950f56396..cb61e412c449371c19d6a8690b252642c2b5fc02 100644 --- a/selftests/all/functional/avocado/basic_tests.py +++ b/selftests/all/functional/avocado/basic_tests.py @@ -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)