avocado
avocado copied to clipboard
selftests/safeloader.sh: unittest.loader raises ImportError
Describe the bug
The selftests/safeloader.sh
uses the standard Python unittest code to find tests, and then compares it with its own "safeloader" result. Under some specific environments, the Python unittest.loader
code is raising an ImportError
exception. The module in question has a file of the same name in two different locations (selftests/unit
and selftests/functional
) so that may be playing a part on the failure.
Steps to reproduce It happens when the GH "Pre-release tests" Action is run, under "Run 'make check'".
Expected behavior A test pass.
Current behavior Can be seen here
[stdout] *** Checking safeloader on selftests/unit/test_dependencies_resolver.py ***
[stdout] *** Checking safeloader on selftests/unit/test_dispatcher.py ***
[stdout] *** Checking safeloader on selftests/unit/test_hintfiles.py ***
[stdout] *** Checking safeloader on selftests/unit/test_parameters.py ***
[stdout] *** Checking safeloader on selftests/unit/test_parser.py ***
[stdout] *** Checking safeloader on selftests/unit/test_plugin_interfaces.py ***
[stdout] *** Checking safeloader on selftests/unit/test_result.py ***
[stdout] *** Checking safeloader on selftests/unit/test_runner_asset.py ***
[stderr] Traceback (most recent call last):
[stderr] File "/home/runner/work/avocado/avocado/contrib/scripts/find-python-unittest", line 51, in <module>
[stderr] suite = loader.discover(start_dir, pattern)
[stderr] File "/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/unittest/loader.py", line 349, in discover
[stderr] tests = list(self._find_tests(start_dir, pattern))
[stderr] File "/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/unittest/loader.py", line 405, in _find_tests
[stderr] tests, should_recurse = self._find_test_path(
[stderr] File "/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/unittest/loader.py", line 458, in _find_test_path
[stderr] raise ImportError(
[stderr] ImportError: 'test_runner_asset' module incorrectly imported from '/home/runner/work/avocado/avocado/selftests/functional'. Expected '/home/runner/work/avocado/avocado/selftests/unit'. Is this module globally installed?
System information (please complete the following information):
- OS: Ubuntu 20.04 on GH Actions
- Avocado version: a79461a145e44de482ff7a3670147e3c51b809b5
- Avocado installation method: git
Additional information I was not able to reproduce it on my environment. According to @richtja , he has seen this error before on his environment.