Skip to content

Commit

Permalink
[test_display_callback] Use ANSIBLE_PYTHON_INTERPRETER var
Browse files Browse the repository at this point in the history
Fixes test issues with new versions of ansible that have this patch:

  ansible/ansible#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.
  • Loading branch information
NickLaMuro committed Sep 5, 2019
1 parent 5b0046a commit 3fb10f0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/integration/test_display_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,15 +15,21 @@

HERE = os.path.abspath(os.path.dirname(__file__))

@pytest.fixture()
def default_envvars():
return {
"ANSIBLE_PYTHON_INTERPRETER": ANSIBLE_PYTHON_INTERPRETER,
"ANSIBLE_DEPRECATION_WARNINGS": "False"
}

@pytest.fixture()
def executor(tmpdir, request):
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,
Expand Down Expand Up @@ -167,11 +175,11 @@ 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
])
def test_callback_plugin_task_args_leak(executor, playbook):
def test_callback_plugin_task_args_leak(executor, playbook, default_envvars):
executor.run()
events = list(executor.events)
assert events[0]['event'] == 'playbook_on_start'
Expand Down

0 comments on commit 3fb10f0

Please sign in to comment.