From a40b145f29d33273dd21de28c6a7612612af77bc Mon Sep 17 00:00:00 2001 From: Ruchi Pakhle Date: Wed, 13 Sep 2023 17:20:12 +0530 Subject: [PATCH] changes --- src/pytest_ansible/plugin.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/pytest_ansible/plugin.py b/src/pytest_ansible/plugin.py index 1866d68b..c792f59c 100644 --- a/src/pytest_ansible/plugin.py +++ b/src/pytest_ansible/plugin.py @@ -246,7 +246,7 @@ def pytest_generate_tests(metafunc): raise pytest.UsageError(exception) # Return the host name as a string - metafunc.parametrize("ansible_host", hosts.keys()) + metafunc.parametrize("ansible_host", iter(hosts[h] for h in hosts)) if "ansible_group" in metafunc.fixturenames: # assert required --ansible-* parameters were used @@ -259,15 +259,11 @@ def pytest_generate_tests(metafunc): ) except ansible.errors.AnsibleError as exception: raise pytest.UsageError(exception) - - # Fetch groups using inventory manager - inventory_manager = hosts.options["inventory_manager"] - groups = inventory_manager.list_groups() + groups = hosts.options["inventory_manager"].list_groups() extra_groups = hosts.get_extra_inventory_groups() - - # Return the group names as strings - group_names = groups + extra_groups - metafunc.parametrize("ansible_group", group_names) + # Return the group name as a string + metafunc.parametrize("ansible_group", iter(hosts[g] for g in groups)) + metafunc.parametrize("ansible_group", iter(hosts[g] for g in extra_groups)) if "molecule_scenario" in metafunc.fixturenames: if not HAS_MOLECULE: