-
-
Notifications
You must be signed in to change notification settings - Fork 363
Open
Labels
Description
I'm having trouble getting a simple testinfra
script to execute on a Windows machine. I'm using testinfra
as a part of a stack using ansible
and molecule
, which may or may not be related to the issue.
Here's what my basic test looks like:
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_ps(host):
cmd = host.run('whoami')
This is the error output I'm receiving:
writing pytestdebug information to /<path>/molecule/default/pytestdebug.log
============================= test session starts ==============================
platform darwin -- Python 2.7.15, pytest-4.2.0, py-1.7.0, pluggy-0.8.1 -- /<path>/bin/python2.7
using: pytest-4.2.0 pylib-1.7.0
setuptools registered plugins:
testinfra-1.19.1.dev9+gef92ec3 at /<path>/lib/python2.7/site-packages/testinfra/plugin.py
rootdir: /<path>/molecule/default, inifile:
plugins: testinfra-1.19.1.dev9+gef92ec3
collected 1 item
tests/test_default.py::test_ps[ansible://jhalpert] FAILED [100%]
=================================== FAILURES ===================================
_________________________ test_ps[ansible://jhalpert] __________________________
host = <testinfra.host.Host object at 0x106647950>
def test_ps(host):
> cmd = host.run('whoami')
tests/test_default.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../../../../lib/python2.7/site-packages/testinfra/host.py:71: in run
return self.backend.run(command, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <testinfra.backend.ansible.AnsibleBackend object at 0x1066477d0>
command = 'whoami', args = (), kwargs = {}
out = {'_ansible_no_log': False, '_ansible_parsed': False, 'changed': False, 'module_stderr': 'Exception calling "Create" wi...tegoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : BadExpression
', ...}
def run(self, command, *args, **kwargs):
command = self.get_command(command, *args)
out = self.run_ansible("shell", module_args=command)
return self.result(
out['rc'],
command,
stdout_bytes=None,
stderr_bytes=None,
> stdout=out["stdout"], stderr=out["stderr"],
)
E KeyError: u'stdout'
../../../../../../../lib/python2.7/site-packages/testinfra/backend/ansible.py:48: KeyError
------------------------------ Captured log call -------------------------------
ansible.py 61 INFO RUN Ansible(u'shell', 'whoami', {}): {'_ansible_no_log': False,
'_ansible_parsed': False,
'changed': False,
'module_stderr': u'Exception calling "Create" with "1" argument(s): "At line:4 char:21\r\n+ def _ansiballz_main():\r\n+ ~\r\nAn expression was expected after \'(\'.\r\nAt line:12 char:27\r\n+ except (AttributeError, OSError):\r\n+ ~\r\nMissing argument in parameter list.\r\nAt line:14 char:7\r\n+ if scriptdir is not None:\r\n+ ~\r\nMissing \'(\' after \'if\' in if statement.\r\nAt line:21 char:7\r\n+ if sys.version_info < (3,):\r\n+ ~\r\nMissing \'(\' after \'if\' in if statement.\r\nAt line:21 char:30\r\n+ if sys.version_info < (3,):\r\n+ ~\r\nMissing expression after \',\'.\r\nAt line:21 char:25\r\n+ if sys.version_info < (3,):\r\n+ ~\r\nThe \'<\' operator is reserved for future use.\r\nAt line:23 char:32\r\n+ MOD_DESC = (\'.py\', \'U\', imp.PY_SOURCE)\r\n+ ~\r\nMissing expression after \',\'.\r\nAt line:23 char:33\r\n+ MOD_DESC = (\'.py\', \'U\', imp.PY_SOURCE)\r\n+ ~~~~~~~~~~~~~\r\nUnexpected token \'imp.PY_SOURCE\' in expression or statement.\r\nAt line:23 char:32\r\n+ MOD_DESC = (\'.py\', \'U\', imp.PY_SOURCE)\r\n+ ~\r\nMissing closing \')\' in expression.\r\nAt line:23 char:46\r\n+ MOD_DESC = (\'.py\', \'U\', imp.PY_SOURCE)\r\n+ ~\r\nUnexpected token \')\' in expression or statement.\r\nNot all parse errors were reported. Correct the reported errors and try again."\r\nAt line:6 char:1\r\n+ $exec_wrapper = [ScriptBlock]::Create($split_parts[0])\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (:) [], MethodInvocationException\r\n + FullyQualifiedErrorId : ParseException\r\n \r\nThe expression after \'&\' in a pipeline element produced an object that was not valid. It must result in a command \r\nname, a script block, or a CommandInfo object.\r\nAt line:7 char:2\r\n+ &$exec_wrapper\r\n+ ~~~~~~~~~~~~~\r\n + CategoryInfo : InvalidOperation: (:) [], RuntimeException\r\n + FullyQualifiedErrorId : BadExpression\r\n ',
'module_stdout': u'',
'msg': u'MODULE FAILURE\nSee stdout/stderr for the exact error',
'rc': 1}
========================== deprecated python version ===========================
You are using Python 2.7.15, which will no longer be supported in pytest 5.0
For more information, please read:
https://docs.pytest.org/en/latest/py27-py34-deprecation.html
=========================== 1 failed in 2.39 seconds ===========================
wrote pytestdebug information to /<path>/molecule/default/pytestdebug.log
I've tried with both testinfra 1.16.0 and the current git master branch (1.19.1.dev). Any help you can offer is appreciated!