From 3d450f0f22bb208902d7e0eeba7b010309f041dd Mon Sep 17 00:00:00 2001 From: Klaus Zerwes Date: Fri, 10 Dec 2021 09:49:28 +0100 Subject: [PATCH] fix interpreter discovery tests for changed python interpreter behaviour from ansible 2.12 on --- .../ansible_2_8_tests.yml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/ansible/integration/interpreter_discovery/ansible_2_8_tests.yml b/tests/ansible/integration/interpreter_discovery/ansible_2_8_tests.yml index 2dea4f8b..9b974c6d 100644 --- a/tests/ansible/integration/interpreter_discovery/ansible_2_8_tests.yml +++ b/tests/ansible/integration/interpreter_discovery/ansible_2_8_tests.yml @@ -63,15 +63,31 @@ ping: register: legacy - - name: check for dep warning (only on platforms where auto result is not /usr/bin/python and legacy is) + # from ansible 2.12 on this changed + # - https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_5.html#python-interpreter-discovery + # - https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html + # default discovery methot is now auto and will default to python3 + # and the message changed from a deprecation warning to a real warning that can not be suppressed by + # using deprecation_warnings=False + - name: check for dep warning (only on platforms where auto result is not /usr/bin/python and legacy is) for ansible 2.8-2.11 assert: that: - legacy.deprecations | default([]) | length > 0 fail_msg: legacy={{legacy}} # only check for a dep warning if legacy returned /usr/bin/python and auto didn't when: legacy.ansible_facts.discovered_interpreter_python == '/usr/bin/python' and - auto_out.ansible_facts.discovered_interpreter_python != '/usr/bin/python' + auto_out.ansible_facts.discovered_interpreter_python != '/usr/bin/python' and + ansible_version.full is version_compare('2.12.0', '<', strict=True) + - name: check for warning (only on platforms where auto result is not /usr/bin/python and legacy is) from ansible 2.12 on + assert: + that: + - legacy.warnings | default([]) | length > 0 + fail_msg: legacy={{legacy}} + # only check for a warning if legacy returned /usr/bin/python and auto didn't + when: legacy.ansible_facts.discovered_interpreter_python == '/usr/bin/python' and + auto_out.ansible_facts.discovered_interpreter_python != '/usr/bin/python' and + ansible_version.full is version_compare('2.12.0', '>=', strict=True) - name: test that auto_silent never warns and got the same answer as auto block: