Browse code

Update aci tests for new messages from lxml-4.0+

(cherry picked from commit 1fa3fb45bc65a1eb705ecc2de59e6cbf592b9ae0)

Toshio Kuratomi authored on 2017/09/18 08:48:49
Showing 1 changed files
... ...
@@ -22,6 +22,8 @@ import sys
22 22
 
23 23
 from ansible.compat.tests import unittest
24 24
 from ansible.module_utils.aci import aci_response_json, aci_response_xml
25
+from ansible.module_utils.six import PY2, PY3
26
+from ansible.module_utils._text import to_native
25 27
 
26 28
 from nose.plugins.skip import SkipTest
27 29
 
... ...
@@ -201,7 +203,7 @@ class AciRest(unittest.TestCase):
201 201
     def test_empty_response(self):
202 202
         self.maxDiffi = None
203 203
 
204
-        if sys.version_info < (3, 0):
204
+        if PY2:
205 205
             expected_json_result = {
206 206
                 'error_code': -1,
207 207
                 '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):
231 231
                 'raw': '',
232 232
             }
233 233
 
234
-        elif sys.version_info < (3, 0):
234
+        elif etree.LXML_VERSION < (4, 0, 0, 0):
235
+            error_text = to_native(u"Unable to parse output as XML, see 'raw' output. None (line 0)", errors='surrogate_or_strict')
235 236
             expected_xml_result = {
236 237
                 'error_code': -1,
237
-                'error_text': "Unable to parse output as XML, see 'raw' output. None (line 0)",
238
+                'error_text': error_text,
238 239
                 'raw': '',
239 240
             }
240 241
 
241 242
         else:
243
+            if PY3:
244
+                error_text = u"Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (<string>, line 1)"
245
+            else:
246
+                error_text = "Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (line 1)"
247
+
242 248
             expected_xml_result = {
243
-                u'error_code': -1,
244
-                u'error_text': u"Unable to parse output as XML, see 'raw' output. None (line 0)",
245
-                u'raw': u'',
249
+                'error_code': -1,
250
+                'error_text': error_text,
251
+                'raw': '',
246 252
             }
247 253
 
248 254
         xml_response = ''