提交 1e4fdaa8 编写于 作者: C Cleber Rosa

selftests/unit/test_runner_queue.py: use absolute path for module

Looks like the Python 3 module import code behaves differently than
Python 2 with regards to where it looks modules by name:

   File "/home/cleber/src/avocado/avocado/avocado/core/test.py", line 932, in _run_avocado
      raise test_exception
   File "/home/cleber/src/avocado/avocado/avocado/core/test.py", line 819, in _run_avocado
      testMethod()
   File "/home/cleber/src/avocado/avocado/avocado/core/test.py", line 1371, in test
      self.error(self.exception)
   File "/home/cleber/src/avocado/avocado/avocado/core/test.py", line 1041, in error
      raise exceptions.TestError(message)\navocado.core.exceptions.TestError: Traceback (most recent call last):
   File "/usr/lib64/python3.6/imp.py", line 297, in find_module
      raise ImportError(_ERR_MSG.format(name), name=name)
   ImportError: No module named \'whiteboard\'\n\n'

Effectively, this means when running this test, on Python 3, on the
parallel mode, the change of directory implemented there
(on selftests/checkall) will make Python 3 fail to find this module,
and the test will fail.

This makes the reference to the module path absolute, so no matter
where this test is run from, it should be able to find the module.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 494405ae
......@@ -4,6 +4,7 @@ import tempfile
import unittest
import multiprocessing
import multiprocessing.queues
import os
from avocado.core.job import Job
from avocado.core.result import Result
......@@ -42,12 +43,15 @@ class TestRunnerQueue(unittest.TestCase):
"""
Tests if the whiteboard content is the expected one
"""
this = os.path.abspath(__file__)
base = os.path.dirname(os.path.dirname(os.path.dirname(this)))
module = os.path.join(base, 'examples', 'tests', 'whiteboard.py')
factory = ['WhiteBoard',
{'methodName': 'test',
'tags': set([]),
'params': ([TreeNode(name='')], ['/run/*']),
'job': self.job,
'modulePath': 'examples/tests/whiteboard.py',
'modulePath': module,
'base_logdir': self.tmpdir}]
msg = self._run_test(factory)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册