From 82e15eb1ed886352c17551c88204a65b3b0794ac Mon Sep 17 00:00:00 2001 From: Nick LaMuro Date: Thu, 22 Aug 2019 17:57:47 -0500 Subject: [PATCH] [test_display_callback] Use ANSIBLE_PYTHON_INTERPRETER var Fixes test issues with new versions of ansible that have this patch: https://github.com/ansible/ansible/pull/50163 Since there are tests that end up triggering this warning and mess with the event locations that are returned. Made a quick refactor to the fixture in this test file as well to break out the default env vars so it was a bit more DRY and re-usable. --- test/integration/test_display_callback.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/integration/test_display_callback.py b/test/integration/test_display_callback.py index 2ad4a9c03..27ed3acf3 100644 --- a/test/integration/test_display_callback.py +++ b/test/integration/test_display_callback.py @@ -5,6 +5,8 @@ import yaml import six +from sys import executable as ANSIBLE_PYTHON_INTERPRETER + from ansible import __version__ as ANSIBLE_VERSION from ansible_runner.interface import init_runner @@ -15,13 +17,21 @@ @pytest.fixture() -def executor(tmpdir, request): +def default_envvars(): + return { + "ANSIBLE_PYTHON_INTERPRETER": ANSIBLE_PYTHON_INTERPRETER, + "ANSIBLE_DEPRECATION_WARNINGS": "False" + } + + +@pytest.fixture() +def executor(tmpdir, request, default_envvars): private_data_dir = six.text_type(tmpdir.mkdir('foo')) playbooks = request.node.callspec.params.get('playbook') playbook = list(playbooks.values())[0] envvars = request.node.callspec.params.get('envvars') - envvars = envvars.update({"ANSIBLE_DEPRECATION_WARNINGS": "False"}) if envvars is not None else {"ANSIBLE_DEPRECATION_WARNINGS": "False"} + envvars = envvars.update(default_envvars) if envvars is not None else default_envvars r = init_runner( private_data_dir=private_data_dir, @@ -167,7 +177,7 @@ def test_callback_plugin_no_log_filters(executor, playbook): - shell: echo "PUBLIC" - shell: echo "PRIVATE" no_log: true - - uri: url=https://example.org username="PUBLIC" password="PRIVATE" + - uri: url=https://example.org user="PUBLIC" password="PRIVATE" - copy: content="PRIVATE" dest="/tmp/tmp_no_log" '''}, # noqa ])