-
Notifications
You must be signed in to change notification settings - Fork 69
Description
I am developing an Ansible lookup, and test that using pytest and pytest-ansible.
The pytest test function looks like this (simplified):
import pytest
@pytest.mark.ansible(host_pattern='localhost', connection='local')
def test_mylookup(ansible_module):
expr = "lookup('myorg.mycoll.mylookup', 'someterm')"
contacted = ansible_module.set_fact(result=f"{{{{ {expr} }}}}")
contacted_host = contacted['localhost']
assert 'failed' not in contacted_host
result = contacted_host['ansible_facts']['result']
# assertions on result
Up to pytest-ansible version 24.1.3, this worked fine.
Starting with pytest-ansible version 24.1.4, this fails because the lookup plugin is no longer found, and I get:
contacted_host={
'failed': True,
'msg': 'lookup plugin (ibm.zvpc.image_filename) not found',
'_ansible_no_log': False
}
The lookup plugin is installed and available for Ansible. ansible-galaxy collection list shows the collection with the lookup plugin as installed in /Users/maiera/.ansible/collections/ansible_collections and I did verify that up to version 24.1.3, the code in that install directory gets control during the test. I have no ANSIBLE env vars set, and no ansible.cfg file. ansible-config dump reports:
COLLECTIONS_PATHS(default) = ['/Users/maiera/.ansible/collections', '/usr/share/ansible/collections']
So my collection is found by Ansible using this default configuration.
Pytest command line:
pytest --cov=myproject --cov-config .coveragerc --cov-append --cov-report=term-missing -s --ansible-host-pattern localhost test
Why is the lookup no longer found starting with pytest-ansible version 24.1.4?
Is this something I can fix, or does this require a fix by pytest-ansible?
As a workaround, I am pinning pytest-ansible<=24.1.4 at the moment, to have my tests working.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status