fix the variable collision issue in downstream tests (#364)

* fix the variable collision issue

* make output format in such a way that it returns a dict

* changes

* changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* revert back changes

* changes

* changes

* fix the error

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add dict construct

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
pull/358/head
Ruchi Pakhle 2024-08-01 23:44:14 +05:30 committed by GitHub
parent 540e0d8963
commit 1df7af5ab2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -44,7 +44,7 @@ def from_xml(data, engine):
if not HAS_XMLTODICT:
_raise_error("Missing required library xmltodict")
try:
res = xmltodict.parse(data)
res = xmltodict.parse(data, dict_constructor=dict)
except Exception:
_raise_error("Input Xml is not valid")
return res

View File

@ -19,10 +19,12 @@
- name: Integration tests with and without default engine as xmltodict and
ansible.builtin.assert:
that: "{{ output == item.test }}"
that: "{{ output == test_item.test }}"
loop:
- test: "{{ data | ansible.utils.from_xml() }}"
- test: "{{ data | ansible.utils.from_xml('xmltodict') }}"
loop_control:
loop_var: test_item
- name: Setup invalid xml as input to ansible.utils.from_xml.
ansible.builtin.set_fact: