blob: ff0dec9d7a9571c39f0048cd33b18de400e6aa10 [file] [log] [blame]
Facundo Batista5a3b5242007-07-13 10:43:44 +00001import base64
Fred Drakeba613c32005-02-10 18:33:30 +00002import datetime
Skip Montanaro3e7bba92001-10-19 16:06:52 +00003import sys
Facundo Batista5a3b5242007-07-13 10:43:44 +00004import time
Skip Montanaro419abda2001-10-01 17:47:44 +00005import unittest
6import xmlrpclib
Facundo Batistaa53872b2007-08-14 13:35:00 +00007import SimpleXMLRPCServer
8import threading
Facundo Batista7f686fc2007-08-17 19:16:44 +00009import mimetools
Georg Brandl5d1b4d42007-12-07 09:07:10 +000010import httplib
11import socket
Jeremy Hylton89420112008-11-24 22:00:29 +000012import StringIO
Georg Brandl5d1b4d42007-12-07 09:07:10 +000013import os
Senthil Kumaran20d114c2009-04-01 20:26:33 +000014import re
Barry Warsaw04f357c2002-07-23 19:04:11 +000015from test import test_support
Skip Montanaro419abda2001-10-01 17:47:44 +000016
Fred Drake22c07062005-02-11 17:59:08 +000017try:
18 unicode
19except NameError:
20 have_unicode = False
21else:
22 have_unicode = True
23
Skip Montanaro419abda2001-10-01 17:47:44 +000024alist = [{'astring': 'foo@bar.baz.spam',
25 'afloat': 7283.43,
Skip Montanaro3e7bba92001-10-19 16:06:52 +000026 'anint': 2**20,
27 'ashortlong': 2L,
Skip Montanaro419abda2001-10-01 17:47:44 +000028 'anotherlist': ['.zyx.41'],
29 'abase64': xmlrpclib.Binary("my dog has fleas"),
30 'boolean': xmlrpclib.False,
Andrew M. Kuchlingb12d97c2004-06-05 12:33:27 +000031 'unicode': u'\u4000\u6000\u8000',
32 u'ukey\u4000': 'regular value',
Fred Drakeba613c32005-02-10 18:33:30 +000033 'datetime1': xmlrpclib.DateTime('20050210T11:41:23'),
34 'datetime2': xmlrpclib.DateTime(
35 (2005, 02, 10, 11, 41, 23, 0, 1, -1)),
36 'datetime3': xmlrpclib.DateTime(
37 datetime.datetime(2005, 02, 10, 11, 41, 23)),
Skip Montanaro419abda2001-10-01 17:47:44 +000038 }]
39
40class XMLRPCTestCase(unittest.TestCase):
41
42 def test_dump_load(self):
43 self.assertEquals(alist,
44 xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0])
45
Fred Drakeba613c32005-02-10 18:33:30 +000046 def test_dump_bare_datetime(self):
Skip Montanaro174dd222005-05-14 20:54:16 +000047 # This checks that an unwrapped datetime.date object can be handled
48 # by the marshalling code. This can't be done via test_dump_load()
49 # since with use_datetime set to 1 the unmarshaller would create
50 # datetime objects for the 'datetime[123]' keys as well
Fred Drakeba613c32005-02-10 18:33:30 +000051 dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
52 s = xmlrpclib.dumps((dt,))
Skip Montanaro174dd222005-05-14 20:54:16 +000053 (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
54 self.assertEquals(newdt, dt)
Fred Drakeba613c32005-02-10 18:33:30 +000055 self.assertEquals(m, None)
56
Skip Montanaro174dd222005-05-14 20:54:16 +000057 (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
58 self.assertEquals(newdt, xmlrpclib.DateTime('20050210T11:41:23'))
59
Skip Montanarob131f042008-04-18 20:35:46 +000060 def test_datetime_before_1900(self):
Andrew M. Kuchlinga5489d42008-04-21 01:45:57 +000061 # same as before but with a date before 1900
Skip Montanarob131f042008-04-18 20:35:46 +000062 dt = datetime.datetime(1, 02, 10, 11, 41, 23)
63 s = xmlrpclib.dumps((dt,))
64 (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
65 self.assertEquals(newdt, dt)
66 self.assertEquals(m, None)
67
68 (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
69 self.assertEquals(newdt, xmlrpclib.DateTime('00010210T11:41:23'))
70
Andrew M. Kuchling085f75a2008-02-23 16:23:05 +000071 def test_cmp_datetime_DateTime(self):
72 now = datetime.datetime.now()
73 dt = xmlrpclib.DateTime(now.timetuple())
Benjamin Peterson5c8da862009-06-30 22:57:08 +000074 self.assertTrue(dt == now)
75 self.assertTrue(now == dt)
Andrew M. Kuchling085f75a2008-02-23 16:23:05 +000076 then = now + datetime.timedelta(seconds=4)
Benjamin Peterson5c8da862009-06-30 22:57:08 +000077 self.assertTrue(then >= dt)
78 self.assertTrue(dt < then)
Skip Montanaro174dd222005-05-14 20:54:16 +000079
Andrew M. Kuchlingbdb39012005-12-04 19:11:17 +000080 def test_bug_1164912 (self):
81 d = xmlrpclib.DateTime()
Tim Peters536cf992005-12-25 23:18:31 +000082 ((new_d,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((d,),
Andrew M. Kuchlingbdb39012005-12-04 19:11:17 +000083 methodresponse=True))
Benjamin Peterson5c8da862009-06-30 22:57:08 +000084 self.assertTrue(isinstance(new_d.value, str))
Andrew M. Kuchlingbdb39012005-12-04 19:11:17 +000085
86 # Check that the output of dumps() is still an 8-bit string
87 s = xmlrpclib.dumps((new_d,), methodresponse=True)
Benjamin Peterson5c8da862009-06-30 22:57:08 +000088 self.assertTrue(isinstance(s, str))
Andrew M. Kuchlingbdb39012005-12-04 19:11:17 +000089
Martin v. Löwis07529352006-11-19 18:51:54 +000090 def test_newstyle_class(self):
91 class T(object):
92 pass
93 t = T()
94 t.x = 100
95 t.y = "Hello"
96 ((t2,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((t,)))
97 self.assertEquals(t2, t.__dict__)
98
Skip Montanaro3e7bba92001-10-19 16:06:52 +000099 def test_dump_big_long(self):
100 self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,))
101
102 def test_dump_bad_dict(self):
103 self.assertRaises(TypeError, xmlrpclib.dumps, ({(1,2,3): 1},))
104
Facundo Batista5a3b5242007-07-13 10:43:44 +0000105 def test_dump_recursive_seq(self):
106 l = [1,2,3]
107 t = [3,4,5,l]
108 l.append(t)
109 self.assertRaises(TypeError, xmlrpclib.dumps, (l,))
110
111 def test_dump_recursive_dict(self):
112 d = {'1':1, '2':1}
113 t = {'3':3, 'd':d}
114 d['t'] = t
115 self.assertRaises(TypeError, xmlrpclib.dumps, (d,))
116
Skip Montanaro3e7bba92001-10-19 16:06:52 +0000117 def test_dump_big_int(self):
118 if sys.maxint > 2L**31-1:
119 self.assertRaises(OverflowError, xmlrpclib.dumps,
120 (int(2L**34),))
121
Facundo Batista5a3b5242007-07-13 10:43:44 +0000122 xmlrpclib.dumps((xmlrpclib.MAXINT, xmlrpclib.MININT))
123 self.assertRaises(OverflowError, xmlrpclib.dumps, (xmlrpclib.MAXINT+1,))
124 self.assertRaises(OverflowError, xmlrpclib.dumps, (xmlrpclib.MININT-1,))
125
126 def dummy_write(s):
127 pass
128
129 m = xmlrpclib.Marshaller()
130 m.dump_int(xmlrpclib.MAXINT, dummy_write)
131 m.dump_int(xmlrpclib.MININT, dummy_write)
132 self.assertRaises(OverflowError, m.dump_int, xmlrpclib.MAXINT+1, dummy_write)
133 self.assertRaises(OverflowError, m.dump_int, xmlrpclib.MININT-1, dummy_write)
134
135
Andrew M. Kuchling0b852032003-04-25 00:27:24 +0000136 def test_dump_none(self):
137 value = alist + [None]
138 arg1 = (alist + [None],)
139 strg = xmlrpclib.dumps(arg1, allow_none=True)
140 self.assertEquals(value,
141 xmlrpclib.loads(strg)[0][0])
142 self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,))
143
Fred Drake22c07062005-02-11 17:59:08 +0000144 def test_default_encoding_issues(self):
145 # SF bug #1115989: wrong decoding in '_stringify'
146 utf8 = """<?xml version='1.0' encoding='iso-8859-1'?>
147 <params>
148 <param><value>
149 <string>abc \x95</string>
150 </value></param>
151 <param><value>
152 <struct>
153 <member>
154 <name>def \x96</name>
155 <value><string>ghi \x97</string></value>
156 </member>
157 </struct>
158 </value></param>
159 </params>
160 """
Tim Petersf754f5f2005-04-08 18:00:59 +0000161
162 # sys.setdefaultencoding() normally doesn't exist after site.py is
163 # loaded. reload(sys) is the way to get it back.
Fred Drake22c07062005-02-11 17:59:08 +0000164 old_encoding = sys.getdefaultencoding()
Tim Petersf754f5f2005-04-08 18:00:59 +0000165 setdefaultencoding_existed = hasattr(sys, "setdefaultencoding")
Fred Drake22c07062005-02-11 17:59:08 +0000166 reload(sys) # ugh!
167 sys.setdefaultencoding("iso-8859-1")
168 try:
169 (s, d), m = xmlrpclib.loads(utf8)
170 finally:
171 sys.setdefaultencoding(old_encoding)
Tim Petersf754f5f2005-04-08 18:00:59 +0000172 if not setdefaultencoding_existed:
173 del sys.setdefaultencoding
174
Fred Drake22c07062005-02-11 17:59:08 +0000175 items = d.items()
176 if have_unicode:
177 self.assertEquals(s, u"abc \x95")
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000178 self.assertTrue(isinstance(s, unicode))
Fred Drake22c07062005-02-11 17:59:08 +0000179 self.assertEquals(items, [(u"def \x96", u"ghi \x97")])
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000180 self.assertTrue(isinstance(items[0][0], unicode))
181 self.assertTrue(isinstance(items[0][1], unicode))
Fred Drake22c07062005-02-11 17:59:08 +0000182 else:
183 self.assertEquals(s, "abc \xc2\x95")
184 self.assertEquals(items, [("def \xc2\x96", "ghi \xc2\x97")])
185
Facundo Batista5a3b5242007-07-13 10:43:44 +0000186
187class HelperTestCase(unittest.TestCase):
188 def test_escape(self):
189 self.assertEqual(xmlrpclib.escape("a&b"), "a&amp;b")
190 self.assertEqual(xmlrpclib.escape("a<b"), "a&lt;b")
191 self.assertEqual(xmlrpclib.escape("a>b"), "a&gt;b")
192
193class FaultTestCase(unittest.TestCase):
194 def test_repr(self):
195 f = xmlrpclib.Fault(42, 'Test Fault')
196 self.assertEqual(repr(f), "<Fault 42: 'Test Fault'>")
197 self.assertEqual(repr(f), str(f))
198
199 def test_dump_fault(self):
200 f = xmlrpclib.Fault(42, 'Test Fault')
201 s = xmlrpclib.dumps((f,))
202 (newf,), m = xmlrpclib.loads(s)
203 self.assertEquals(newf, {'faultCode': 42, 'faultString': 'Test Fault'})
204 self.assertEquals(m, None)
205
206 s = xmlrpclib.Marshaller().dumps(f)
207 self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, s)
208
209
210class DateTimeTestCase(unittest.TestCase):
211 def test_default(self):
212 t = xmlrpclib.DateTime()
213
214 def test_time(self):
215 d = 1181399930.036952
216 t = xmlrpclib.DateTime(d)
217 self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", time.localtime(d)))
218
219 def test_time_tuple(self):
220 d = (2007,6,9,10,38,50,5,160,0)
221 t = xmlrpclib.DateTime(d)
222 self.assertEqual(str(t), '20070609T10:38:50')
223
224 def test_time_struct(self):
225 d = time.localtime(1181399930.036952)
226 t = xmlrpclib.DateTime(d)
227 self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", d))
228
229 def test_datetime_datetime(self):
230 d = datetime.datetime(2007,1,2,3,4,5)
231 t = xmlrpclib.DateTime(d)
232 self.assertEqual(str(t), '20070102T03:04:05')
233
Facundo Batista5a3b5242007-07-13 10:43:44 +0000234 def test_repr(self):
235 d = datetime.datetime(2007,1,2,3,4,5)
236 t = xmlrpclib.DateTime(d)
237 val ="<DateTime '20070102T03:04:05' at %x>" % id(t)
238 self.assertEqual(repr(t), val)
239
240 def test_decode(self):
241 d = ' 20070908T07:11:13 '
242 t1 = xmlrpclib.DateTime()
243 t1.decode(d)
244 tref = xmlrpclib.DateTime(datetime.datetime(2007,9,8,7,11,13))
245 self.assertEqual(t1, tref)
246
247 t2 = xmlrpclib._datetime(d)
248 self.assertEqual(t1, tref)
249
250class BinaryTestCase(unittest.TestCase):
251 def test_default(self):
252 t = xmlrpclib.Binary()
253 self.assertEqual(str(t), '')
254
255 def test_string(self):
256 d = '\x01\x02\x03abc123\xff\xfe'
257 t = xmlrpclib.Binary(d)
258 self.assertEqual(str(t), d)
259
260 def test_decode(self):
261 d = '\x01\x02\x03abc123\xff\xfe'
262 de = base64.encodestring(d)
263 t1 = xmlrpclib.Binary()
264 t1.decode(de)
265 self.assertEqual(str(t1), d)
266
267 t2 = xmlrpclib._binary(de)
268 self.assertEqual(str(t2), d)
269
270
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000271ADDR = PORT = URL = None
Skip Montanaro419abda2001-10-01 17:47:44 +0000272
Neal Norwitz653272f2008-01-26 07:26:12 +0000273# The evt is set twice. First when the server is ready to serve.
274# Second when the server has been shutdown. The user must clear
275# the event after it has been set the first time to catch the second set.
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000276def http_server(evt, numrequests, requestHandler=None):
Facundo Batistaa53872b2007-08-14 13:35:00 +0000277 class TestInstanceClass:
278 def div(self, x, y):
Facundo Batistaa53872b2007-08-14 13:35:00 +0000279 return x // y
280
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000281 def _methodHelp(self, name):
282 if name == 'div':
283 return 'This is the div function'
284
285 def my_function():
286 '''This is my function'''
287 return True
288
Neal Norwitz70cea582008-03-28 06:34:03 +0000289 class MyXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
290 def get_request(self):
291 # Ensure the socket is always non-blocking. On Linux, socket
292 # attributes are not inherited like they are on *BSD and Windows.
293 s, port = self.socket.accept()
294 s.setblocking(True)
295 return s, port
296
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000297 if not requestHandler:
298 requestHandler = SimpleXMLRPCServer.SimpleXMLRPCRequestHandler
299 serv = MyXMLRPCServer(("localhost", 0), requestHandler,
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000300 logRequests=False, bind_and_activate=False)
Facundo Batistaa53872b2007-08-14 13:35:00 +0000301 try:
302 serv.socket.settimeout(3)
303 serv.server_bind()
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000304 global ADDR, PORT, URL
305 ADDR, PORT = serv.socket.getsockname()
306 #connect to IP address directly. This avoids socket.create_connection()
307 #trying to connect to to "localhost" using all address families, which
308 #causes slowdown e.g. on vista which supports AF_INET6. The server listens
309 #on AF_INET only.
310 URL = "http://%s:%d"%(ADDR, PORT)
Facundo Batistaa53872b2007-08-14 13:35:00 +0000311 serv.server_activate()
312 serv.register_introspection_functions()
313 serv.register_multicall_functions()
314 serv.register_function(pow)
315 serv.register_function(lambda x,y: x+y, 'add')
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000316 serv.register_function(my_function)
Facundo Batistaa53872b2007-08-14 13:35:00 +0000317 serv.register_instance(TestInstanceClass())
Neal Norwitz653272f2008-01-26 07:26:12 +0000318 evt.set()
Facundo Batistaa53872b2007-08-14 13:35:00 +0000319
320 # handle up to 'numrequests' requests
321 while numrequests > 0:
322 serv.handle_request()
323 numrequests -= 1
324
325 except socket.timeout:
326 pass
327 finally:
328 serv.socket.close()
329 PORT = None
330 evt.set()
331
Neal Norwitz08b50eb2008-01-26 08:26:00 +0000332# This function prevents errors like:
333# <ProtocolError for localhost:57527/RPC2: 500 Internal Server Error>
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000334def is_unavailable_exception(e):
335 '''Returns True if the given ProtocolError is the product of a server-side
336 exception caused by the 'temporarily unavailable' response sometimes
337 given by operations on non-blocking sockets.'''
Neal Norwitz653272f2008-01-26 07:26:12 +0000338
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000339 # sometimes we get a -1 error code and/or empty headers
Neal Norwitzed444e52008-01-27 18:19:04 +0000340 try:
341 if e.errcode == -1 or e.headers is None:
342 return True
343 exc_mess = e.headers.get('X-exception')
344 except AttributeError:
345 # Ignore socket.errors here.
346 exc_mess = str(e)
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000347
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000348 if exc_mess and 'temporarily unavailable' in exc_mess.lower():
349 return True
350
351 return False
352
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000353class BaseServerTestCase(unittest.TestCase):
354 requestHandler = None
Facundo Batistaa53872b2007-08-14 13:35:00 +0000355 def setUp(self):
Facundo Batista7f686fc2007-08-17 19:16:44 +0000356 # enable traceback reporting
357 SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True
358
Facundo Batistaa53872b2007-08-14 13:35:00 +0000359 self.evt = threading.Event()
Facundo Batista7f686fc2007-08-17 19:16:44 +0000360 # start server thread to handle requests
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000361 serv_args = (self.evt, 1, self.requestHandler)
Facundo Batista7f686fc2007-08-17 19:16:44 +0000362 threading.Thread(target=http_server, args=serv_args).start()
Facundo Batistaa53872b2007-08-14 13:35:00 +0000363
Neal Norwitz653272f2008-01-26 07:26:12 +0000364 # wait for the server to be ready
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000365 self.evt.wait(10)
Neal Norwitz653272f2008-01-26 07:26:12 +0000366 self.evt.clear()
Facundo Batistaa53872b2007-08-14 13:35:00 +0000367
368 def tearDown(self):
369 # wait on the server thread to terminate
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000370 self.evt.wait(10)
Facundo Batistaa53872b2007-08-14 13:35:00 +0000371
Facundo Batista7f686fc2007-08-17 19:16:44 +0000372 # disable traceback reporting
373 SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = False
374
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000375# NOTE: The tests in SimpleServerTestCase will ignore failures caused by
376# "temporarily unavailable" exceptions raised in SimpleXMLRPCServer. This
377# condition occurs infrequently on some platforms, frequently on others, and
378# is apparently caused by using SimpleXMLRPCServer with a non-blocking socket
379# If the server class is updated at some point in the future to handle this
380# situation more gracefully, these tests should be modified appropriately.
381
382class SimpleServerTestCase(BaseServerTestCase):
Facundo Batistaa53872b2007-08-14 13:35:00 +0000383 def test_simple1(self):
Facundo Batistac65a5f12007-08-21 00:16:21 +0000384 try:
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000385 p = xmlrpclib.ServerProxy(URL)
Facundo Batistac65a5f12007-08-21 00:16:21 +0000386 self.assertEqual(p.pow(6,8), 6**8)
Neal Norwitz183c5342008-01-27 17:11:11 +0000387 except (xmlrpclib.ProtocolError, socket.error), e:
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000388 # ignore failures due to non-blocking socket 'unavailable' errors
389 if not is_unavailable_exception(e):
390 # protocol error; provide additional information in test output
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000391 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
Facundo Batistaa53872b2007-08-14 13:35:00 +0000392
Senthil Kumaran20d114c2009-04-01 20:26:33 +0000393 def test_nonascii(self):
394 start_string = 'P\N{LATIN SMALL LETTER Y WITH CIRCUMFLEX}t'
395 end_string = 'h\N{LATIN SMALL LETTER O WITH HORN}n'
396
397 try:
398 p = xmlrpclib.ServerProxy(URL)
399 self.assertEqual(p.add(start_string, end_string),
400 start_string + end_string)
401 except (xmlrpclib.ProtocolError, socket.error) as e:
402 # ignore failures due to non-blocking socket unavailable errors.
403 if not is_unavailable_exception(e):
404 # protocol error; provide additional information in test output
405 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
406
407
Christian Heimes6c29be52008-01-19 16:39:27 +0000408 # [ch] The test 404 is causing lots of false alarms.
409 def XXXtest_404(self):
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000410 # send POST with httplib, it should return 404 header and
411 # 'Not Found' message.
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000412 conn = httplib.HTTPConnection(ADDR, PORT)
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000413 conn.request('POST', '/this-is-not-valid')
414 response = conn.getresponse()
415 conn.close()
416
417 self.assertEqual(response.status, 404)
418 self.assertEqual(response.reason, 'Not Found')
419
Facundo Batistaa53872b2007-08-14 13:35:00 +0000420 def test_introspection1(self):
Facundo Batistac65a5f12007-08-21 00:16:21 +0000421 try:
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000422 p = xmlrpclib.ServerProxy(URL)
Facundo Batistac65a5f12007-08-21 00:16:21 +0000423 meth = p.system.listMethods()
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000424 expected_methods = set(['pow', 'div', 'my_function', 'add',
425 'system.listMethods', 'system.methodHelp',
426 'system.methodSignature', 'system.multicall'])
Facundo Batistac65a5f12007-08-21 00:16:21 +0000427 self.assertEqual(set(meth), expected_methods)
Neal Norwitz183c5342008-01-27 17:11:11 +0000428 except (xmlrpclib.ProtocolError, socket.error), e:
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000429 # ignore failures due to non-blocking socket 'unavailable' errors
430 if not is_unavailable_exception(e):
431 # protocol error; provide additional information in test output
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000432 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
Facundo Batistaa53872b2007-08-14 13:35:00 +0000433
434 def test_introspection2(self):
Facundo Batistac65a5f12007-08-21 00:16:21 +0000435 try:
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000436 # test _methodHelp()
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000437 p = xmlrpclib.ServerProxy(URL)
Facundo Batistac65a5f12007-08-21 00:16:21 +0000438 divhelp = p.system.methodHelp('div')
439 self.assertEqual(divhelp, 'This is the div function')
Neal Norwitz183c5342008-01-27 17:11:11 +0000440 except (xmlrpclib.ProtocolError, socket.error), e:
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000441 # ignore failures due to non-blocking socket 'unavailable' errors
442 if not is_unavailable_exception(e):
443 # protocol error; provide additional information in test output
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000444 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
Facundo Batistaa53872b2007-08-14 13:35:00 +0000445
446 def test_introspection3(self):
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000447 try:
448 # test native doc
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000449 p = xmlrpclib.ServerProxy(URL)
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000450 myfunction = p.system.methodHelp('my_function')
451 self.assertEqual(myfunction, 'This is my function')
Neal Norwitz183c5342008-01-27 17:11:11 +0000452 except (xmlrpclib.ProtocolError, socket.error), e:
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000453 # ignore failures due to non-blocking socket 'unavailable' errors
454 if not is_unavailable_exception(e):
455 # protocol error; provide additional information in test output
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000456 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000457
458 def test_introspection4(self):
Facundo Batistaa53872b2007-08-14 13:35:00 +0000459 # the SimpleXMLRPCServer doesn't support signatures, but
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000460 # at least check that we can try making the call
Facundo Batistac65a5f12007-08-21 00:16:21 +0000461 try:
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000462 p = xmlrpclib.ServerProxy(URL)
Facundo Batistac65a5f12007-08-21 00:16:21 +0000463 divsig = p.system.methodSignature('div')
464 self.assertEqual(divsig, 'signatures not supported')
Neal Norwitz183c5342008-01-27 17:11:11 +0000465 except (xmlrpclib.ProtocolError, socket.error), e:
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000466 # ignore failures due to non-blocking socket 'unavailable' errors
467 if not is_unavailable_exception(e):
468 # protocol error; provide additional information in test output
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000469 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
Facundo Batistaa53872b2007-08-14 13:35:00 +0000470
471 def test_multicall(self):
Facundo Batistac65a5f12007-08-21 00:16:21 +0000472 try:
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000473 p = xmlrpclib.ServerProxy(URL)
Facundo Batistac65a5f12007-08-21 00:16:21 +0000474 multicall = xmlrpclib.MultiCall(p)
475 multicall.add(2,3)
476 multicall.pow(6,8)
477 multicall.div(127,42)
478 add_result, pow_result, div_result = multicall()
479 self.assertEqual(add_result, 2+3)
480 self.assertEqual(pow_result, 6**8)
481 self.assertEqual(div_result, 127//42)
Neal Norwitz183c5342008-01-27 17:11:11 +0000482 except (xmlrpclib.ProtocolError, socket.error), e:
Facundo Batistaf91ad6a2007-08-27 01:15:34 +0000483 # ignore failures due to non-blocking socket 'unavailable' errors
484 if not is_unavailable_exception(e):
485 # protocol error; provide additional information in test output
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000486 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
Facundo Batistaa53872b2007-08-14 13:35:00 +0000487
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000488 def test_non_existing_multicall(self):
489 try:
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000490 p = xmlrpclib.ServerProxy(URL)
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000491 multicall = xmlrpclib.MultiCall(p)
492 multicall.this_is_not_exists()
493 result = multicall()
494
495 # result.results contains;
496 # [{'faultCode': 1, 'faultString': '<type \'exceptions.Exception\'>:'
497 # 'method "this_is_not_exists" is not supported'>}]
498
499 self.assertEqual(result.results[0]['faultCode'], 1)
500 self.assertEqual(result.results[0]['faultString'],
501 '<type \'exceptions.Exception\'>:method "this_is_not_exists" '
502 'is not supported')
Neal Norwitz183c5342008-01-27 17:11:11 +0000503 except (xmlrpclib.ProtocolError, socket.error), e:
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000504 # ignore failures due to non-blocking socket 'unavailable' errors
505 if not is_unavailable_exception(e):
506 # protocol error; provide additional information in test output
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000507 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000508
509 def test_dotted_attribute(self):
Neal Norwitz162d7192008-03-23 04:08:30 +0000510 # Raises an AttributeError because private methods are not allowed.
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000511 self.assertRaises(AttributeError,
512 SimpleXMLRPCServer.resolve_dotted_attribute, str, '__add')
513
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000514 self.assertTrue(SimpleXMLRPCServer.resolve_dotted_attribute(str, 'title'))
Neal Norwitz162d7192008-03-23 04:08:30 +0000515 # Get the test to run faster by sending a request with test_simple1.
516 # This avoids waiting for the socket timeout.
517 self.test_simple1()
Facundo Batistaa53872b2007-08-14 13:35:00 +0000518
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000519#A test case that verifies that a server using the HTTP/1.1 keep-alive mechanism
520#does indeed serve subsequent requests on the same connection
521class KeepaliveServerTestCase(BaseServerTestCase):
522 #a request handler that supports keep-alive and logs requests into a
523 #class variable
524 class RequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
525 parentClass = SimpleXMLRPCServer.SimpleXMLRPCRequestHandler
526 protocol_version = 'HTTP/1.1'
527 myRequests = []
528 def handle(self):
529 self.myRequests.append([])
530 return self.parentClass.handle(self)
531 def handle_one_request(self):
532 result = self.parentClass.handle_one_request(self)
533 self.myRequests[-1].append(self.raw_requestline)
534 return result
535
536 requestHandler = RequestHandler
537 def setUp(self):
538 #clear request log
539 self.RequestHandler.myRequests = []
540 return BaseServerTestCase.setUp(self)
541
542 def test_two(self):
543 p = xmlrpclib.ServerProxy(URL)
544 self.assertEqual(p.pow(6,8), 6**8)
545 self.assertEqual(p.pow(6,8), 6**8)
546 self.assertEqual(len(self.RequestHandler.myRequests), 1)
547 #we may or may not catch the final "append" with the empty line
548 self.assertTrue(len(self.RequestHandler.myRequests[-1]) >= 2)
549
550#A test case that verifies that gzip encoding works in both directions
551#(for a request and the response)
552class GzipServerTestCase(BaseServerTestCase):
553 #a request handler that supports keep-alive and logs requests into a
554 #class variable
555 class RequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
556 parentClass = SimpleXMLRPCServer.SimpleXMLRPCRequestHandler
557 protocol_version = 'HTTP/1.1'
558
559 def do_POST(self):
560 #store content of last request in class
561 self.__class__.content_length = int(self.headers["content-length"])
562 return self.parentClass.do_POST(self)
563 requestHandler = RequestHandler
564
565 class Transport(xmlrpclib.Transport):
566 #custom transport, stores the response length for our perusal
567 fake_gzip = False
568 def parse_response(self, response):
569 self.response_length=int(response.getheader("content-length", 0))
570 return xmlrpclib.Transport.parse_response(self, response)
571
572 def send_content(self, connection, body):
573 if self.fake_gzip:
574 #add a lone gzip header to induce decode error remotely
575 connection.putheader("Content-Encoding", "gzip")
576 return xmlrpclib.Transport.send_content(self, connection, body)
577
578 def test_gzip_request(self):
579 t = self.Transport()
580 t.encode_threshold = None
581 p = xmlrpclib.ServerProxy(URL, transport=t)
582 self.assertEqual(p.pow(6,8), 6**8)
583 a = self.RequestHandler.content_length
584 t.encode_threshold = 0 #turn on request encoding
585 self.assertEqual(p.pow(6,8), 6**8)
586 b = self.RequestHandler.content_length
587 self.assertTrue(a>b)
588
589 def test_bad_gzip_request(self):
590 t = self.Transport()
591 t.encode_threshold = None
592 t.fake_gzip = True
593 p = xmlrpclib.ServerProxy(URL, transport=t)
594 cm = self.assertRaisesRegexp(xmlrpclib.ProtocolError,
595 re.compile(r"\b400\b"))
596 with cm:
597 p.pow(6, 8)
598
599 def test_gsip_response(self):
600 t = self.Transport()
601 p = xmlrpclib.ServerProxy(URL, transport=t)
602 old = self.requestHandler.encode_threshold
603 self.requestHandler.encode_threshold = None #no encoding
604 self.assertEqual(p.pow(6,8), 6**8)
605 a = t.response_length
606 self.requestHandler.encode_threshold = 0 #always encode
607 self.assertEqual(p.pow(6,8), 6**8)
608 b = t.response_length
609 self.requestHandler.encode_threshold = old
610 self.assertTrue(a>b)
611
612#Test special attributes of the ServerProxy object
613class ServerProxyTestCase(unittest.TestCase):
614 def test_close(self):
615 p = xmlrpclib.ServerProxy(URL)
616 self.assertEqual(p('close')(), None)
617
618 def test_transport(self):
619 t = xmlrpclib.Transport()
620 p = xmlrpclib.ServerProxy(URL, transport=t)
621 self.assertEqual(p('transport'), t)
622
Facundo Batista7f686fc2007-08-17 19:16:44 +0000623# This is a contrived way to make a failure occur on the server side
624# in order to test the _send_traceback_header flag on the server
625class FailingMessageClass(mimetools.Message):
626 def __getitem__(self, key):
627 key = key.lower()
628 if key == 'content-length':
629 return 'I am broken'
630 return mimetools.Message.__getitem__(self, key)
631
632
633class FailingServerTestCase(unittest.TestCase):
634 def setUp(self):
635 self.evt = threading.Event()
636 # start server thread to handle requests
Neal Norwitz162d7192008-03-23 04:08:30 +0000637 serv_args = (self.evt, 1)
Facundo Batista7f686fc2007-08-17 19:16:44 +0000638 threading.Thread(target=http_server, args=serv_args).start()
639
Neal Norwitz653272f2008-01-26 07:26:12 +0000640 # wait for the server to be ready
641 self.evt.wait()
642 self.evt.clear()
Facundo Batista7f686fc2007-08-17 19:16:44 +0000643
644 def tearDown(self):
645 # wait on the server thread to terminate
646 self.evt.wait()
647 # reset flag
648 SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = False
649 # reset message class
650 SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = mimetools.Message
651
652 def test_basic(self):
653 # check that flag is false by default
654 flagval = SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header
655 self.assertEqual(flagval, False)
656
Facundo Batistac65a5f12007-08-21 00:16:21 +0000657 # enable traceback reporting
658 SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True
659
660 # test a call that shouldn't fail just as a smoke test
661 try:
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000662 p = xmlrpclib.ServerProxy(URL)
Facundo Batistac65a5f12007-08-21 00:16:21 +0000663 self.assertEqual(p.pow(6,8), 6**8)
Neal Norwitz183c5342008-01-27 17:11:11 +0000664 except (xmlrpclib.ProtocolError, socket.error), e:
Facundo Batista492e5922007-08-29 10:28:28 +0000665 # ignore failures due to non-blocking socket 'unavailable' errors
666 if not is_unavailable_exception(e):
667 # protocol error; provide additional information in test output
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000668 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
Facundo Batista7f686fc2007-08-17 19:16:44 +0000669
670 def test_fail_no_info(self):
671 # use the broken message class
672 SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
673
674 try:
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000675 p = xmlrpclib.ServerProxy(URL)
Facundo Batista7f686fc2007-08-17 19:16:44 +0000676 p.pow(6,8)
Neal Norwitz183c5342008-01-27 17:11:11 +0000677 except (xmlrpclib.ProtocolError, socket.error), e:
Facundo Batista492e5922007-08-29 10:28:28 +0000678 # ignore failures due to non-blocking socket 'unavailable' errors
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000679 if not is_unavailable_exception(e) and hasattr(e, "headers"):
Facundo Batista492e5922007-08-29 10:28:28 +0000680 # The two server-side error headers shouldn't be sent back in this case
681 self.assertTrue(e.headers.get("X-exception") is None)
682 self.assertTrue(e.headers.get("X-traceback") is None)
Facundo Batista7f686fc2007-08-17 19:16:44 +0000683 else:
684 self.fail('ProtocolError not raised')
685
686 def test_fail_with_info(self):
687 # use the broken message class
688 SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
689
690 # Check that errors in the server send back exception/traceback
691 # info when flag is set
692 SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True
693
694 try:
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000695 p = xmlrpclib.ServerProxy(URL)
Facundo Batista7f686fc2007-08-17 19:16:44 +0000696 p.pow(6,8)
Neal Norwitz183c5342008-01-27 17:11:11 +0000697 except (xmlrpclib.ProtocolError, socket.error), e:
Facundo Batista492e5922007-08-29 10:28:28 +0000698 # ignore failures due to non-blocking socket 'unavailable' errors
Neal Norwitzcf25eb12008-01-27 20:03:13 +0000699 if not is_unavailable_exception(e) and hasattr(e, "headers"):
Facundo Batista492e5922007-08-29 10:28:28 +0000700 # We should get error info in the response
701 expected_err = "invalid literal for int() with base 10: 'I am broken'"
702 self.assertEqual(e.headers.get("x-exception"), expected_err)
703 self.assertTrue(e.headers.get("x-traceback") is not None)
Facundo Batista7f686fc2007-08-17 19:16:44 +0000704 else:
705 self.fail('ProtocolError not raised')
706
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000707class CGIHandlerTestCase(unittest.TestCase):
708 def setUp(self):
709 self.cgi = SimpleXMLRPCServer.CGIXMLRPCRequestHandler()
710
711 def tearDown(self):
712 self.cgi = None
713
714 def test_cgi_get(self):
Walter Dörwald4b965f62009-04-26 20:51:44 +0000715 with test_support.EnvironmentVarGuard() as env:
Walter Dörwald6733bed2009-05-01 17:35:37 +0000716 env['REQUEST_METHOD'] = 'GET'
Walter Dörwald4b965f62009-04-26 20:51:44 +0000717 # if the method is GET and no request_text is given, it runs handle_get
718 # get sysout output
719 tmp = sys.stdout
720 sys.stdout = open(test_support.TESTFN, "w")
721 self.cgi.handle_request()
722 sys.stdout.close()
723 sys.stdout = tmp
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000724
Walter Dörwald4b965f62009-04-26 20:51:44 +0000725 # parse Status header
726 handle = open(test_support.TESTFN, "r").read()
727 status = handle.split()[1]
728 message = ' '.join(handle.split()[2:4])
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000729
Walter Dörwald4b965f62009-04-26 20:51:44 +0000730 self.assertEqual(status, '400')
731 self.assertEqual(message, 'Bad Request')
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000732
Walter Dörwald4b965f62009-04-26 20:51:44 +0000733 os.remove(test_support.TESTFN)
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000734
735 def test_cgi_xmlrpc_response(self):
736 data = """<?xml version='1.0'?>
737<methodCall>
738 <methodName>test_method</methodName>
739 <params>
740 <param>
741 <value><string>foo</string></value>
742 </param>
743 <param>
744 <value><string>bar</string></value>
745 </param>
746 </params>
747</methodCall>
748"""
749 open("xmldata.txt", "w").write(data)
750 tmp1 = sys.stdin
751 tmp2 = sys.stdout
752
753 sys.stdin = open("xmldata.txt", "r")
754 sys.stdout = open(test_support.TESTFN, "w")
755
Walter Dörwald4b965f62009-04-26 20:51:44 +0000756 with test_support.EnvironmentVarGuard() as env:
Walter Dörwald6733bed2009-05-01 17:35:37 +0000757 env['CONTENT_LENGTH'] = str(len(data))
Georg Brandl61fce382009-04-01 15:23:43 +0000758 self.cgi.handle_request()
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000759
760 sys.stdin.close()
761 sys.stdout.close()
762 sys.stdin = tmp1
763 sys.stdout = tmp2
764
765 # will respond exception, if so, our goal is achieved ;)
766 handle = open(test_support.TESTFN, "r").read()
767
768 # start with 44th char so as not to get http header, we just need only xml
769 self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:])
770
Senthil Kumaran20d114c2009-04-01 20:26:33 +0000771 # Also test the content-length returned by handle_request
772 # Using the same test method inorder to avoid all the datapassing
773 # boilerplate code.
774 # Test for bug: http://bugs.python.org/issue5040
775
776 content = handle[handle.find("<?xml"):]
777
778 self.assertEquals(
779 int(re.search('Content-Length: (\d+)', handle).group(1)),
780 len(content))
781
782
Georg Brandl5d1b4d42007-12-07 09:07:10 +0000783 os.remove("xmldata.txt")
784 os.remove(test_support.TESTFN)
Facundo Batista7f686fc2007-08-17 19:16:44 +0000785
Jeremy Hylton89420112008-11-24 22:00:29 +0000786class FakeSocket:
787
788 def __init__(self):
789 self.data = StringIO.StringIO()
790
791 def send(self, buf):
792 self.data.write(buf)
793 return len(buf)
794
795 def sendall(self, buf):
796 self.data.write(buf)
797
798 def getvalue(self):
799 return self.data.getvalue()
800
Kristján Valur Jónsson3c43fcb2009-01-11 16:23:37 +0000801 def makefile(self, x='r', y=-1):
Jeremy Hylton89420112008-11-24 22:00:29 +0000802 raise RuntimeError
803
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000804 def close(self):
805 pass
806
Jeremy Hylton89420112008-11-24 22:00:29 +0000807class FakeTransport(xmlrpclib.Transport):
808 """A Transport instance that records instead of sending a request.
809
810 This class replaces the actual socket used by httplib with a
811 FakeSocket object that records the request. It doesn't provide a
812 response.
813 """
814
815 def make_connection(self, host):
816 conn = xmlrpclib.Transport.make_connection(self, host)
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000817 conn.sock = self.fake_socket = FakeSocket()
Jeremy Hylton89420112008-11-24 22:00:29 +0000818 return conn
819
820class TransportSubclassTestCase(unittest.TestCase):
821
822 def issue_request(self, transport_class):
823 """Return an HTTP request made via transport_class."""
824 transport = transport_class()
825 proxy = xmlrpclib.ServerProxy("http://example.com/",
826 transport=transport)
827 try:
828 proxy.pow(6, 8)
829 except RuntimeError:
830 return transport.fake_socket.getvalue()
831 return None
832
833 def test_custom_user_agent(self):
834 class TestTransport(FakeTransport):
835
836 def send_user_agent(self, conn):
837 xmlrpclib.Transport.send_user_agent(self, conn)
838 conn.putheader("X-Test", "test_custom_user_agent")
839
840 req = self.issue_request(TestTransport)
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000841 self.assertTrue("X-Test: test_custom_user_agent\r\n" in req)
Jeremy Hylton89420112008-11-24 22:00:29 +0000842
843 def test_send_host(self):
844 class TestTransport(FakeTransport):
845
846 def send_host(self, conn, host):
847 xmlrpclib.Transport.send_host(self, conn, host)
848 conn.putheader("X-Test", "test_send_host")
849
850 req = self.issue_request(TestTransport)
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000851 self.assertTrue("X-Test: test_send_host\r\n" in req)
Jeremy Hylton89420112008-11-24 22:00:29 +0000852
853 def test_send_request(self):
854 class TestTransport(FakeTransport):
855
856 def send_request(self, conn, url, body):
857 xmlrpclib.Transport.send_request(self, conn, url, body)
858 conn.putheader("X-Test", "test_send_request")
859
860 req = self.issue_request(TestTransport)
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000861 self.assertTrue("X-Test: test_send_request\r\n" in req)
Jeremy Hylton89420112008-11-24 22:00:29 +0000862
863 def test_send_content(self):
864 class TestTransport(FakeTransport):
865
866 def send_content(self, conn, body):
867 conn.putheader("X-Test", "test_send_content")
868 xmlrpclib.Transport.send_content(self, conn, body)
869
870 req = self.issue_request(TestTransport)
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000871 self.assertTrue("X-Test: test_send_content\r\n" in req)
Jeremy Hylton89420112008-11-24 22:00:29 +0000872
Facundo Batistaa53872b2007-08-14 13:35:00 +0000873def test_main():
874 xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
Jeremy Hylton89420112008-11-24 22:00:29 +0000875 BinaryTestCase, FaultTestCase, TransportSubclassTestCase]
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000876 xmlrpc_tests.append(SimpleServerTestCase)
Kristján Valur Jónssone0078602009-06-28 21:04:17 +0000877 xmlrpc_tests.append(KeepaliveServerTestCase)
878 xmlrpc_tests.append(GzipServerTestCase)
879 xmlrpc_tests.append(ServerProxyTestCase)
Kristján Valur Jónsson018760e2009-01-14 10:50:57 +0000880 xmlrpc_tests.append(FailingServerTestCase)
881 xmlrpc_tests.append(CGIHandlerTestCase)
Facundo Batistaa53872b2007-08-14 13:35:00 +0000882
883 test_support.run_unittest(*xmlrpc_tests)
Skip Montanaro419abda2001-10-01 17:47:44 +0000884
885if __name__ == "__main__":
886 test_main()