@@ -184,19 +184,26 @@ def test_dump_none(self):
184
184
self .assertRaises (TypeError , xmlrpclib .dumps , (arg1 ,))
185
185
186
186
def test_dump_encoding (self ):
187
- value = '\u20ac '
187
+ value = {'key\u20ac \xa4 ' :
188
+ 'value\u20ac \xa4 ' }
188
189
strg = xmlrpclib .dumps ((value ,), encoding = 'iso-8859-15' )
189
190
strg = "<?xml version='1.0' encoding='iso-8859-15'?>" + strg
190
191
self .assertEqual (xmlrpclib .loads (strg )[0 ][0 ], value )
191
- strg = strg .encode ('iso-8859-15' )
192
+ strg = strg .encode ('iso-8859-15' , 'xmlcharrefreplace' )
192
193
self .assertEqual (xmlrpclib .loads (strg )[0 ][0 ], value )
193
194
194
195
strg = xmlrpclib .dumps ((value ,), encoding = 'iso-8859-15' ,
195
196
methodresponse = True )
196
197
self .assertEqual (xmlrpclib .loads (strg )[0 ][0 ], value )
197
- strg = strg .encode ('iso-8859-15' )
198
+ strg = strg .encode ('iso-8859-15' , 'xmlcharrefreplace' )
198
199
self .assertEqual (xmlrpclib .loads (strg )[0 ][0 ], value )
199
200
201
+ methodname = 'method\u20ac \xa4 '
202
+ strg = xmlrpclib .dumps ((value ,), encoding = 'iso-8859-15' ,
203
+ methodname = methodname )
204
+ self .assertEqual (xmlrpclib .loads (strg )[0 ][0 ], value )
205
+ self .assertEqual (xmlrpclib .loads (strg )[1 ], methodname )
206
+
200
207
def test_dump_bytes (self ):
201
208
sample = b"my dog has fleas"
202
209
self .assertEqual (sample , xmlrpclib .Binary (sample ))
@@ -430,6 +437,7 @@ def get_request(self):
430
437
serv .register_multicall_functions ()
431
438
serv .register_function (pow )
432
439
serv .register_function (lambda x ,y : x + y , 'add' )
440
+ serv .register_function (lambda x : x , 'têšt' )
433
441
serv .register_function (my_function )
434
442
testInstance = TestInstanceClass ()
435
443
serv .register_instance (testInstance , allow_dotted_names = True )
@@ -599,7 +607,7 @@ def test_nonascii(self):
599
607
600
608
def test_client_encoding (self ):
601
609
start_string = '\u20ac '
602
- end_string = '\xa3 '
610
+ end_string = '\xa4 '
603
611
604
612
try :
605
613
p = xmlrpclib .ServerProxy (URL , encoding = 'iso-8859-15' )
@@ -611,6 +619,16 @@ def test_client_encoding(self):
611
619
# protocol error; provide additional information in test output
612
620
self .fail ("%s\n %s" % (e , getattr (e , "headers" , "" )))
613
621
622
+ def test_nonascii_methodname (self ):
623
+ try :
624
+ p = xmlrpclib .ServerProxy (URL , encoding = 'ascii' )
625
+ self .assertEqual (p .têšt (42 ), 42 )
626
+ except (xmlrpclib .ProtocolError , socket .error ) as e :
627
+ # ignore failures due to non-blocking socket unavailable errors.
628
+ if not is_unavailable_exception (e ):
629
+ # protocol error; provide additional information in test output
630
+ self .fail ("%s\n %s" % (e , getattr (e , "headers" , "" )))
631
+
614
632
# [ch] The test 404 is causing lots of false alarms.
615
633
def XXXtest_404 (self ):
616
634
# send POST with http.client, it should return 404 header and
@@ -624,7 +642,7 @@ def XXXtest_404(self):
624
642
self .assertEqual (response .reason , 'Not Found' )
625
643
626
644
def test_introspection1 (self ):
627
- expected_methods = set (['pow' , 'div' , 'my_function' , 'add' ,
645
+ expected_methods = set (['pow' , 'div' , 'my_function' , 'add' , 'têšt' ,
628
646
'system.listMethods' , 'system.methodHelp' ,
629
647
'system.methodSignature' , 'system.multicall' ,
630
648
'Fixture' ])
@@ -767,7 +785,7 @@ def threadFunc(evt, numrequests, requestHandler=None, encoding=None):
767
785
768
786
def test_server_encoding (self ):
769
787
start_string = '\u20ac '
770
- end_string = '\xa3 '
788
+ end_string = '\xa4 '
771
789
772
790
try :
773
791
p = xmlrpclib .ServerProxy (URL )
0 commit comments