Open
Description
Hi,
I tried to replace the host
fixture with an own implementation to skip test modules based on Ansible groups. I simply created a new host
fixture in tests/conftest.py
.
$ cat hosts
[local]
localhost
[skip_test_mytest_file]
mytesttarget
$ cat tests/conftest.py
import pytest
@pytest.fixture(scope='module')
def host(host, request):
for groupname in host.ansible.get_variables()["group_names"]:
if groupname.startswith("skip_%s" % request.module.__name__):
pytest.skip()
return host
But unfortunately the code fails with:
request = <SubRequest '_testinfra_host' for <Function test_mytest>>
@pytest.fixture(scope="module")
def _testinfra_host(request):
> return request.param
E AttributeError: 'SubRequest' object has no attribute 'param'
../../virtualenv/lib64/python3.10/site-packages/testinfra/plugin.py:28: AttributeError
It looks like the optional param
attribute is missing and this triggers the issue.
pytest-testinfra/testinfra/plugin.py
Lines 26 to 33 in f921bb8
The current workaround is to name the new fixture ansiblehost
and use it in my code. However, this leads to a lot of code changes.
Please provide a possibility to replace the host
fixture with an own implementation.
Thank you,
Carsten
Metadata
Metadata
Assignees
Labels
No labels