fixed tests, and removed the action hack code

pull/658/head
Steven Robertson 5 years ago
parent 7411057ba8
commit 33e7d0804f

@ -504,9 +504,7 @@ class Connection(ansible.plugins.connection.ConnectionBase):
loader_basedir = None loader_basedir = None
# set by `_get_task_vars()` for interpreter discovery # 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 _action = None
# running interpreter discovery fully
_action = type(str('actionTemp'), (object,), {'_finding_python_interpreter': False})
def __del__(self): def __del__(self):
""" """
@ -778,7 +776,6 @@ class Connection(ansible.plugins.connection.ConnectionBase):
play_context=self._play_context, play_context=self._play_context,
transport=self.transport, transport=self.transport,
inventory_name=self.get_task_var('inventory_hostname'), inventory_name=self.get_task_var('inventory_hostname'),
action=self._action
) )
stack = self._stack_from_spec(spec) stack = self._stack_from_spec(spec)
return spec.inventory_name(), stack return spec.inventory_name(), stack

@ -397,14 +397,14 @@ class PlayContextSpec(Spec):
PlayContext. It is used for normal connections and delegate_to connections, PlayContext. It is used for normal connections and delegate_to connections,
and should always be accurate. 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._connection = connection
self._play_context = play_context self._play_context = play_context
self._transport = transport self._transport = transport
self._inventory_name = inventory_name self._inventory_name = inventory_name
self._task_vars = self._connection._get_task_vars() self._task_vars = self._connection._get_task_vars()
# used to run interpreter discovery # used to run interpreter discovery
self._action = action self._action = connection._action
def transport(self): def transport(self):
return self._transport return self._transport

@ -47,11 +47,15 @@ class ConnectionMixin(MuxProcessMixin):
def make_connection(self): def make_connection(self):
play_context = ansible.playbook.play_context.PlayContext() play_context = ansible.playbook.play_context.PlayContext()
conn = self.klass(play_context, new_stdin=False) 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( conn.on_action_run(
task_vars={}, task_vars={},
delegate_to_hostname=None, delegate_to_hostname=None,
loader_basedir=None, loader_basedir=None,
) )
return conn return conn
def wait_for_completion(self): def wait_for_completion(self):

Loading…
Cancel
Save