diff --git a/selftests/unit/test_job.py b/selftests/unit/test_job.py index a45d2861ae0f66b69ddaffa1cc4e93f79b0616c8..1fad48a0434013d52002e35715e90f0669458f2d 100644 --- a/selftests/unit/test_job.py +++ b/selftests/unit/test_job.py @@ -4,6 +4,11 @@ import shutil import tempfile import unittest +try: + from unittest import mock +except ImportError: + import mock + from avocado.core import data_dir from avocado.core import exceptions from avocado.core import exit_codes @@ -157,6 +162,15 @@ class JobTest(unittest.TestCase): empty_job = job.Job(args) self.assertIsNotNone(empty_job.args.unique_job_id) + def test_job_no_base_logdir(self): + args = argparse.Namespace() + with mock.patch('avocado.core.job.data_dir.get_logs_dir', + return_value=self.tmpdir): + empty_job = job.Job(args) + self.assertTrue(os.path.isdir(empty_job.logdir)) + self.assertEqual(os.path.dirname(empty_job.logdir), self.tmpdir) + self.assertTrue(os.path.isfile(os.path.join(empty_job.logdir, 'id'))) + def tearDown(self): data_dir._tmp_tracker.unittest_refresh_dir_tracker() shutil.rmtree(self.tmpdir)