Skip to content

Commit 1df7af5

Browse files
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>
1 parent 540e0d8 commit 1df7af5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

plugins/plugin_utils/from_xml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def from_xml(data, engine):
4444
if not HAS_XMLTODICT:
4545
_raise_error("Missing required library xmltodict")
4646
try:
47-
res = xmltodict.parse(data)
47+
res = xmltodict.parse(data, dict_constructor=dict)
4848
except Exception:
4949
_raise_error("Input Xml is not valid")
5050
return res

tests/integration/targets/utils_from_xml/tasks/simple.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919

2020
- name: Integration tests with and without default engine as xmltodict and
2121
ansible.builtin.assert:
22-
that: "{{ output == item.test }}"
22+
that: "{{ output == test_item.test }}"
2323
loop:
2424
- test: "{{ data | ansible.utils.from_xml() }}"
2525
- test: "{{ data | ansible.utils.from_xml('xmltodict') }}"
26+
loop_control:
27+
loop_var: test_item
2628

2729
- name: Setup invalid xml as input to ansible.utils.from_xml.
2830
ansible.builtin.set_fact:

0 commit comments

Comments
 (0)