pytest-testinfra
pytest-testinfra copied to clipboard
Question about windows support - error when running a simple facter test
Hi,
this is a question regarding windows support. In the documentation it is said that in testinfra v3.0.0 the windows support was improved. That is the only "windows" reference in the whole documentation. My question is: What is supported under Windows actually?
I am asking in particular since I am getting an error when running testinfra on a windows environment:
PS C:\MyProject\packer> C:\Python39\python -m pytest -v test_infra.py --junit-xml junit.xml
========================================================================== test session starts ===========================================================================
platform win32 -- Python 3.9.1, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- C:\Python39\python.exe
cachedir: .pytest_cache
rootdir: C:\MyProject\packer
plugins: testinfra-6.1.0
collected 2 items
test_infra.py::test_puppet_facts[local] FAILED [ 50%]
================================================================================ FAILURES ================================================================================
________________________________________________________________________ test_puppet_facts[local] ________________________________________________________________________
host = <testinfra.host.Host local>
def test_puppet_facts(host):
> facts = host.facter()
test_infra.py:2:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Python39\lib\site-packages\testinfra\modules\puppet.py:105: in __call__
return json.loads(self.check_output(cmd))
c:\python39\lib\site-packages\testinfra\host.py:75: in run
return self.backend.run(command, *args, **kwargs)
c:\python39\lib\site-packages\testinfra\backend\local.py:30: in run
return self.run_local(self.get_command(command, *args))
c:\python39\lib\site-packages\testinfra\backend\base.py:192: in run_local
p = subprocess.Popen(
C:\Python39\lib\subprocess.py:947: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Popen: returncode: None args: [102, 97, 99, 116, 101, 114, 32, 45, 45, 106,...>, args = b'facter --json --puppet ', executable = None, preexec_fn = None
close_fds = True, pass_fds = (), cwd = None, env = None, startupinfo = None, creationflags = 0, shell = True, p2cread = Handle(648), p2cwrite = 14, c2pread = 15
c2pwrite = Handle(652), errread = 16, errwrite = Handle(660), unused_restore_signals = True, unused_gid = None, unused_gids = None, unused_uid = None, unused_umask = -1
unused_start_new_session = False
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
unused_restore_signals,
unused_gid, unused_gids, unused_uid,
unused_umask,
unused_start_new_session):
"""Execute program (MS Windows version)"""
assert not pass_fds, "pass_fds not supported on Windows."
if isinstance(args, str):
pass
elif isinstance(args, bytes):
if shell:
> raise TypeError('bytes args is not allowed on Windows')
E TypeError: bytes args is not allowed on Windows
C:\Python39\lib\subprocess.py:1348: TypeError
This is the test I am executing
def test_puppet_facts(host):
facts = host.facter()
assert facts["operatingsystem"] == "windows"