Fix xml test version check.

This commit is contained in:
Matt Clay 2019-03-28 17:11:39 -07:00
parent 5f29058941
commit b6d30a5825

View file

@ -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