From ec85902b37094ad4ee0e603e21ec12ee19856b40 Mon Sep 17 00:00:00 2001 From: Stevenson Michel Date: Thu, 21 May 2026 13:38:52 -0400 Subject: [PATCH] Fix awx-collection tests for ansible-core 2.21.0 (#16455) Fix awx-collection tests for ansible-core 2.21.0 compat ansible-core 2.21.0 introduced _PARSED_MODULE_ARGS in module_utils/basic.py, used by _return_formatted() to conditionally include invocation data. The awx_collection test harness bypasses normal arg parsing via _load_params mock, leaving this variable as None and causing AttributeError on every exit_json/fail_json call. Mock _PARSED_MODULE_ARGS with _ansible_inject_invocation=True to match the pre-2.21 behavior of always including invocation data. --- awx_collection/test/awx/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/awx_collection/test/awx/conftest.py b/awx_collection/test/awx/conftest.py index 371ae66014..4fe89f8b72 100644 --- a/awx_collection/test/awx/conftest.py +++ b/awx_collection/test/awx/conftest.py @@ -236,6 +236,7 @@ def run_module(request, collection_import, mocker): with mock.patch.object(resource_class, '_load_params', new=mock_load_params): mocker.patch('ansible.module_utils.basic._ANSIBLE_PROFILE', 'legacy') + mocker.patch('ansible.module_utils.basic._PARSED_MODULE_ARGS', {'_ansible_inject_invocation': True}, create=True) with mock.patch('ansible.module_utils.urls.Request.open', new=new_open): with _get_tower_cli_mgr(new_request):