From 33e7d0804fc6b2eb4ec7c56fb86fbf0c6d7f7927 Mon Sep 17 00:00:00 2001 From: Steven Robertson Date: Wed, 4 Mar 2020 16:05:29 -0800 Subject: [PATCH] fixed tests, and removed the action hack code --- ansible_mitogen/connection.py | 5 +---- ansible_mitogen/transport_config.py | 4 ++-- tests/ansible/tests/connection_test.py | 4 ++++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index 3410d7a4..45e5ee5e 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -504,9 +504,7 @@ class Connection(ansible.plugins.connection.ConnectionBase): loader_basedir = None # set by `_get_task_vars()` for interpreter discovery - # we need it to be an object with the value of "_finding_python_interpreter" in case we aren't - # running interpreter discovery fully - _action = type(str('actionTemp'), (object,), {'_finding_python_interpreter': False}) + _action = None def __del__(self): """ @@ -778,7 +776,6 @@ class Connection(ansible.plugins.connection.ConnectionBase): play_context=self._play_context, transport=self.transport, inventory_name=self.get_task_var('inventory_hostname'), - action=self._action ) stack = self._stack_from_spec(spec) return spec.inventory_name(), stack diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index 5b8cfd2c..2a7a1e58 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -397,14 +397,14 @@ class PlayContextSpec(Spec): PlayContext. It is used for normal connections and delegate_to connections, and should always be accurate. """ - def __init__(self, connection, play_context, transport, inventory_name, action): + def __init__(self, connection, play_context, transport, inventory_name): self._connection = connection self._play_context = play_context self._transport = transport self._inventory_name = inventory_name self._task_vars = self._connection._get_task_vars() # used to run interpreter discovery - self._action = action + self._action = connection._action def transport(self): return self._transport diff --git a/tests/ansible/tests/connection_test.py b/tests/ansible/tests/connection_test.py index 71e1d042..e6578954 100644 --- a/tests/ansible/tests/connection_test.py +++ b/tests/ansible/tests/connection_test.py @@ -47,11 +47,15 @@ class ConnectionMixin(MuxProcessMixin): def make_connection(self): play_context = ansible.playbook.play_context.PlayContext() conn = self.klass(play_context, new_stdin=False) + # conn functions don't fetch ActionModuleMixin objs from _get_task_vars() + # through the usual walk-the-stack approach so we'll not run interpreter discovery here + conn._action = mock.MagicMock(_possible_python_interpreter='/usr/bin/python') conn.on_action_run( task_vars={}, delegate_to_hostname=None, loader_basedir=None, ) + return conn def wait_for_completion(self):