From b6d30a58258183e42f54248d7d4b536ed7fb680d Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 28 Mar 2019 17:11:39 -0700 Subject: [PATCH] Fix xml test version check. --- test/integration/targets/xml/tasks/main.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/test/integration/targets/xml/tasks/main.yml b/test/integration/targets/xml/tasks/main.yml index 35b6abe6eb2..ca47f1be047 100644 --- a/test/integration/targets/xml/tasks/main.yml +++ b/test/integration/targets/xml/tasks/main.yml @@ -14,22 +14,18 @@ state: present # when: ansible_os_family == "Darwin" -- name: Get lxml major version - shell: python -c 'from lxml import etree; print(etree.LXML_VERSION[0])' - register: lxml_major_version - -- name: Get lxml minor version - shell: python -c 'from lxml import etree; print(etree.LXML_VERSION[1])' - register: lxml_minor_version +- name: Get lxml version + command: python -c 'from lxml import etree; print(".".join(str(v) for v in etree.LXML_VERSION))' + register: lxml_version - name: Set lxml capabilities as variables set_fact: # NOTE: Some tests require predictable element attribute order, # which is only guaranteed starting from lxml v3.0alpha1 - lxml_predictable_attribute_order: '{{ lxml_major_version.stdout|int >= 3 }}' + lxml_predictable_attribute_order: '{{ lxml_version.stdout is version("3", ">=") }}' # NOTE: The xml module requires at least lxml v2.3.0 - lxml_xpath_attribute_result_attrname: '{{ lxml_major_version.stdout|int >= 2 and lxml_minor_version.stdout|int >= 3 }}' + lxml_xpath_attribute_result_attrname: '{{ lxml_version.stdout is version("2.3.0", ">=") }}' - name: Only run the tests when lxml v2.3.0+ when: lxml_xpath_attribute_result_attrname