diff --git a/avocado/core/test.py b/avocado/core/test.py index 894997c3d055990b76f5a372561d99292feb1fea..99bdc165682f1d33e057f4c2c7f9b8068f981e24 100644 --- a/avocado/core/test.py +++ b/avocado/core/test.py @@ -300,17 +300,6 @@ class Test(unittest.TestCase): """ pass - def runTest(self): - """ - Actual test payload. Must be implemented by tests. - - In case of an existing test suite wrapper, it'll execute the suite, - or perform a series of operations, and based in the results of the - operations decide if the test pass (let the test complete) or fail - (raise a test related exception). - """ - pass - def tearDown(self): """ Cleanup stage after the runTest is done. @@ -345,11 +334,9 @@ class Test(unittest.TestCase): 'Actual:\n%s\nExpected:\n%s' % (actual, expected)) self.assertEqual(expected, actual, msg) - def run(self, result=None): + def _run_avocado(self): """ - Run test method, for compatibility with unittest.TestCase. - - :result: Unused param, compatibiltiy with :class:`unittest.TestCase`. + Auxiliary method to run_avocado. """ testMethod = getattr(self, self._testMethodName) self.start_logging() @@ -437,7 +424,7 @@ class Test(unittest.TestCase): os.environ['AVOCADO_TEST_OUTPUTDIR'] = self.outputdir os.environ['AVOCADO_TEST_SYSINFODIR'] = self.sysinfodir - def run_avocado(self, result=None): + def run_avocado(self): """ Wraps the run method, for execution inside the avocado runner. @@ -446,7 +433,7 @@ class Test(unittest.TestCase): self._setup_environment_variables() try: self.tag_start() - self.run(result) + self._run_avocado() except exceptions.TestBaseException, detail: self.status = detail.status self.fail_class = detail.__class__.__name__ diff --git a/examples/tests/skiponsetup.py b/examples/tests/skiponsetup.py index ae8b8e04768c76cdd89204a4621e6c9d4360cc04..1067f44fca46a600045c69eb860ce9d5a2ae25a4 100644 --- a/examples/tests/skiponsetup.py +++ b/examples/tests/skiponsetup.py @@ -16,5 +16,11 @@ class SkipOnSetupTest(Test): """ self.skip('This should end with SKIP.') + def test_wont_be_executed(self): + """ + This won't get to be executed, given that setUp calls .skip(). + """ + pass + if __name__ == "__main__": main() diff --git a/selftests/all/unit/avocado/jsonresult_unittest.py b/selftests/all/unit/avocado/jsonresult_unittest.py index 29d12c298667ccb37ef311e29d0b62cd64ddf3d0..2186a18378c080ad31ea7501dde1cd3d34fc84b3 100644 --- a/selftests/all/unit/avocado/jsonresult_unittest.py +++ b/selftests/all/unit/avocado/jsonresult_unittest.py @@ -41,6 +41,12 @@ class _Stream(object): class JSONResultTest(unittest.TestCase): def setUp(self): + + class SimpleTest(Test): + + def runTest(self): + pass + self.tmpfile = tempfile.mkstemp() self.tmpdir = tempfile.mkdtemp() args = argparse.Namespace(json_output=self.tmpfile[1]) @@ -49,7 +55,7 @@ class JSONResultTest(unittest.TestCase): self.test_result = jsonresult.JSONTestResult(stream, args) self.test_result.filename = self.tmpfile[1] self.test_result.start_tests() - self.test1 = Test(job=job.Job(), base_logdir=self.tmpdir) + self.test1 = SimpleTest(job=job.Job(), base_logdir=self.tmpdir) self.test1.status = 'PASS' self.test1.time_elapsed = 1.23 diff --git a/selftests/all/unit/avocado/test_unittest.py b/selftests/all/unit/avocado/test_unittest.py index 897e157a2d4d5868e7923d4ec8158d7981d4738a..172af868fb41a2cdf44b56c16f80e11cf5db0380 100644 --- a/selftests/all/unit/avocado/test_unittest.py +++ b/selftests/all/unit/avocado/test_unittest.py @@ -36,26 +36,11 @@ class TestClassTest(unittest.TestCase): self.assertTrue(variable) self.whiteboard = 'foo' - class EmptyTest(test.Test): - - """ - I don't have runTest() defined! - """ - pass - self.base_logdir = tempfile.mkdtemp(prefix='avocado_test_unittest') self.tst_instance_pass = AvocadoPass(base_logdir=self.base_logdir) self.tst_instance_pass.run_avocado() self.tst_instance_pass_new = AvocadoPass(base_logdir=self.base_logdir) self.tst_instance_pass_new.run_avocado() - self.tst_instance_empty = EmptyTest(base_logdir=self.base_logdir) - self.tst_instance_empty.run_avocado() - - def testRunTest(self): - self.assertEqual(self.tst_instance_empty.runTest(), None) - - def testRunAvocado(self): - self.assertEqual(self.tst_instance_empty.status, 'PASS') def testClassAttributesName(self): self.assertEqual(self.tst_instance_pass.name, 'AvocadoPass') diff --git a/selftests/all/unit/avocado/xunit_unittest.py b/selftests/all/unit/avocado/xunit_unittest.py index a1476dc95d1aeaba28e89efc83409ab57ac9a2f8..79f52fa3496714edf936f0c8a71d65b8901dc074 100644 --- a/selftests/all/unit/avocado/xunit_unittest.py +++ b/selftests/all/unit/avocado/xunit_unittest.py @@ -45,13 +45,19 @@ class _Stream(object): class xUnitSucceedTest(unittest.TestCase): def setUp(self): + + class SimpleTest(Test): + + def runTest(self): + pass + self.tmpfile = tempfile.mkstemp() self.tmpdir = tempfile.mkdtemp() args = argparse.Namespace() args.xunit_output = self.tmpfile[1] self.test_result = xunit.xUnitTestResult(stream=_Stream(), args=args) self.test_result.start_tests() - self.test1 = Test(job=job.Job(), base_logdir=self.tmpdir) + self.test1 = SimpleTest(job=job.Job(), base_logdir=self.tmpdir) self.test1.status = 'PASS' self.test1.time_elapsed = 1.23