When running patchtest locally to figure out what was wrong with my
patch, I saw the similar exceptions for each test module:
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/usr/lib/python3.6/unittest/loader.py", line 34, in testFailure
raise self._exception
ImportError: Failed to import test module: tests.test_python_pylint
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/loader.py", line 428, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.6/unittest/loader.py", line 369, in
_get_module_from_name
__import__(name)
File
"/mnt/build/Projects/Konsulko/patchtest/patchtest-oe/tests/test_python_pylint.py",
line 18, in <module>
import base
ModuleNotFoundError: No module named 'base'
To fix this the import patch used when loading test modules has been
extended.
Signed-off-by: Paul Barker <[email protected]>
---
patchtest | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/patchtest b/patchtest
index 59b19f5..a204479 100755
--- a/patchtest
+++ b/patchtest
@@ -138,6 +138,10 @@ def _runner(resultklass, prefix=None):
if prefix:
loader.testMethodPrefix = prefix
+ # allow tests to import helper modules
+ sys.path.insert(0, pti.startdir)
+ sys.path.insert(0, os.path.join(pti.startdir, 'tests'))
+
# create the suite with discovered tests and the corresponding runner
suite = loader.discover(start_dir=pti.startdir, pattern=pti.pattern,
top_level_dir=pti.topdir)
ntc = suite.countTestCases()
--
2.17.1
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto