Fix for issue5040. Adding support for unicode message passing and tests for unicode message and test for Content-Length.
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 1f5f5aa..624793d 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -9,6 +9,7 @@
import http.client
import socket
import os
+import re
from test import support
alist = [{'astring': 'foo@bar.baz.spam',
@@ -352,6 +353,19 @@
# protocol error; provide additional information in test output
self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
+ def test_nonascii(self):
+ start_string = 'P\N{LATIN SMALL LETTER Y WITH CIRCUMFLEX}t'
+ end_string = 'h\N{LATIN SMALL LETTER O WITH HORN}n'
+ try:
+ p = xmlrpclib.ServerProxy(URL)
+ self.assertEqual(p.add(start_string, end_string),
+ start_string + end_string)
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ # ignore failures due to non-blocking socket 'unavailable' errors
+ if not is_unavailable_exception(e):
+ # protocol error; provide additional information in test output
+ self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
+
# [ch] The test 404 is causing lots of false alarms.
def XXXtest_404(self):
# send POST with http.client, it should return 404 header and
@@ -616,9 +630,21 @@
# need only xml
self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:])
+ # Also test the content-length returned by handle_request
+ # Using the same test method inorder to avoid all the datapassing
+ # boilerplate code.
+ # Test for bug: http://bugs.python.org/issue5040
+
+ content = handle[handle.find("<?xml"):]
+
+ self.assertEquals(
+ int(re.search('Content-Length: (\d+)', handle).group(1)),
+ len(content))
+
os.remove("xmldata.txt")
os.remove(support.TESTFN)
+
def test_main():
xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
BinaryTestCase, FaultTestCase]