Skip to content

Commit 5fbd7f9

Browse files
committed
Fix test_51_client for python3
A few more strings/bytes issues and some inconsistency with the way etree works in python3.
1 parent 9ec7705 commit 5fbd7f9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/test_51_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ def add_subelement(xmldoc, node_name, subelem):
7575
while xmldoc[c] == " ":
7676
spaces += " "
7777
c += 1
78+
# Sometimes we get an xml header, sometimes we don't.
79+
subelem_str = str(subelem)
80+
if subelem_str[0:5].lower() == '<?xml':
81+
subelem_str = subelem_str.split("\n", 1)[1]
7882
xmldoc = xmldoc.replace(
7983
"<%s:%s%s/>" % (tag, node_name, spaces),
80-
"<%s:%s%s>%s</%s:%s>" % (tag, node_name, spaces, subelem, tag,
84+
"<%s:%s%s>%s</%s:%s>" % (tag, node_name, spaces, subelem_str, tag,
8185
node_name))
8286

8387
return xmldoc
@@ -829,7 +833,7 @@ def test_sign_then_encrypt_assertion2(self):
829833

830834
#seresp = samlp.response_from_string(enctext)
831835

832-
resp_str = base64.encodestring(enctext)
836+
resp_str = base64.encodestring(enctext.encode('utf-8'))
833837
# Now over to the client side
834838
resp = self.client.parse_authn_request_response(
835839
resp_str, BINDING_HTTP_POST,

0 commit comments

Comments
 (0)