ansible-test - Fix import test when vendoring.

pull/76485/head
Matt Clay 3 years ago
parent 47448f1458
commit 33a8d06332

@ -0,0 +1,2 @@
bugfixes:
- ansible-test - Fix the ``import`` sanity test to work properly when Ansible's built-in vendoring support is in use.

@ -39,6 +39,7 @@ def _ensure_vendored_path_entry():
already_loaded_vendored_modules = set(sys.modules.keys()).intersection(vendored_module_names)
if already_loaded_vendored_modules:
# NOTE: If this message is changed, the matching warning filter in ansible-test must also be updated in `importer.py` for the import sanity test.
warnings.warn('One or more Python packages bundled by this ansible-core distribution were already '
'loaded ({0}). This may result in undefined behavior.'.format(', '.join(sorted(already_loaded_vendored_modules))))

@ -475,6 +475,12 @@ def main():
with warnings.catch_warnings():
warnings.simplefilter('error')
# If vendoring is in use (lib/ansible/_vendor/), then vendored modules may already be loaded after the first file is tested.
# To avoid test failures, the warning about this condition must be ignored.
warnings.filterwarnings(
"ignore",
"One or more Python packages bundled by this ansible-core distribution were already loaded ")
if sys.version_info[0] == 2:
warnings.filterwarnings(
"ignore",

Loading…
Cancel
Save