From 1fa3fb45bc65a1eb705ecc2de59e6cbf592b9ae0 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sun, 17 Sep 2017 16:48:49 -0700 Subject: [PATCH] Update aci tests for new messages from lxml-4.0+ --- test/units/module_utils/test_aci.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/units/module_utils/test_aci.py b/test/units/module_utils/test_aci.py index b216159aea5..fcea0b1ddff 100644 --- a/test/units/module_utils/test_aci.py +++ b/test/units/module_utils/test_aci.py @@ -22,6 +22,8 @@ import sys from ansible.compat.tests import unittest from ansible.module_utils.aci import aci_response_json, aci_response_xml +from ansible.module_utils.six import PY2, PY3 +from ansible.module_utils._text import to_native from nose.plugins.skip import SkipTest @@ -201,7 +203,7 @@ class AciRest(unittest.TestCase): def test_empty_response(self): self.maxDiffi = None - if sys.version_info < (3, 0): + if PY2: expected_json_result = { 'error_code': -1, 'error_text': "Unable to parse output as JSON, see 'raw' output. No JSON object could be decoded", @@ -231,18 +233,24 @@ class AciRest(unittest.TestCase): 'raw': '', } - elif sys.version_info < (3, 0): + elif etree.LXML_VERSION < (4, 0, 0, 0): + error_text = to_native(u"Unable to parse output as XML, see 'raw' output. None (line 0)", errors='surrogate_or_strict') expected_xml_result = { 'error_code': -1, - 'error_text': "Unable to parse output as XML, see 'raw' output. None (line 0)", + 'error_text': error_text, 'raw': '', } else: + if PY3: + error_text = u"Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (, line 1)" + else: + error_text = "Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (line 1)" + expected_xml_result = { - u'error_code': -1, - u'error_text': u"Unable to parse output as XML, see 'raw' output. None (line 0)", - u'raw': u'', + 'error_code': -1, + 'error_text': error_text, + 'raw': '', } xml_response = ''