]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: ElementTree string representation in python3 compatible manner
authorMasashi Honma <masashi.honma@gmail.com>
Mon, 4 Feb 2019 00:30:15 +0000 (02:30 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 4 Feb 2019 10:26:34 +0000 (12:26 +0200)
Use ET.tostring() to avoid implicit bytes/str conversion issues within
ET implementation. Add XML declaration separately to match previous
behavior.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
tests/hwsim/test_ap_wps.py

index e66047cbec892acc66accd1274051dce664044ed..8e9aa33c8eb4f02363f5545223da97eaf8a442b1 100644 (file)
@@ -2806,16 +2806,14 @@ def upnp_soap_action(conn, path, action, include_soap_action=True,
     if neweventmac:
         msg = ET.SubElement(act, "NewWLANEventMAC")
         msg.text = neweventmac
-    tree = ET.ElementTree(root)
-    soap = StringIO()
-    tree.write(soap, xml_declaration=True, encoding='utf-8')
 
     headers = { "Content-type": 'text/xml; charset="utf-8"' }
     if include_soap_action:
         headers["SOAPAction"] = '"urn:schemas-wifialliance-org:service:WFAWLANConfig:1#%s"' % action
     elif soap_action_override:
         headers["SOAPAction"] = soap_action_override
-    conn.request("POST", path, soap.getvalue(), headers)
+    decl = b'<?xml version=\'1.0\' encoding=\'utf8\'?>\n'
+    conn.request("POST", path, decl + ET.tostring(root), headers)
     return conn.getresponse()
 
 def test_ap_wps_upnp(dev, apdev):