From 69f58282bc4434a715a54ecc69a964c9a0642c24 Mon Sep 17 00:00:00 2001 From: Masashi Honma Date: Mon, 4 Feb 2019 02:30:15 +0200 Subject: [PATCH] tests: ElementTree string representation in python3 compatible manner 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 --- tests/hwsim/test_ap_wps.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index e66047cbe..8e9aa33c8 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -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'\n' + conn.request("POST", path, decl + ET.tostring(root), headers) return conn.getresponse() def test_ap_wps_upnp(dev, apdev):