2001-10-19 13:06:52 -03:00
|
|
|
import sys
|
2001-10-01 14:47:44 -03:00
|
|
|
import unittest
|
|
|
|
import xmlrpclib
|
2002-07-23 16:04:11 -03:00
|
|
|
from test import test_support
|
2001-10-01 14:47:44 -03:00
|
|
|
|
|
|
|
alist = [{'astring': 'foo@bar.baz.spam',
|
|
|
|
'afloat': 7283.43,
|
2001-10-19 13:06:52 -03:00
|
|
|
'anint': 2**20,
|
|
|
|
'ashortlong': 2L,
|
2001-10-01 14:47:44 -03:00
|
|
|
'anotherlist': ['.zyx.41'],
|
|
|
|
'abase64': xmlrpclib.Binary("my dog has fleas"),
|
|
|
|
'boolean': xmlrpclib.False,
|
|
|
|
}]
|
|
|
|
|
|
|
|
class XMLRPCTestCase(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_dump_load(self):
|
|
|
|
self.assertEquals(alist,
|
|
|
|
xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0])
|
|
|
|
|
2001-10-19 13:06:52 -03:00
|
|
|
def test_dump_big_long(self):
|
|
|
|
self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,))
|
|
|
|
|
|
|
|
def test_dump_bad_dict(self):
|
|
|
|
self.assertRaises(TypeError, xmlrpclib.dumps, ({(1,2,3): 1},))
|
|
|
|
|
|
|
|
def test_dump_big_int(self):
|
|
|
|
if sys.maxint > 2L**31-1:
|
|
|
|
self.assertRaises(OverflowError, xmlrpclib.dumps,
|
|
|
|
(int(2L**34),))
|
|
|
|
|
2003-04-24 21:27:24 -03:00
|
|
|
def test_dump_none(self):
|
|
|
|
value = alist + [None]
|
|
|
|
arg1 = (alist + [None],)
|
|
|
|
strg = xmlrpclib.dumps(arg1, allow_none=True)
|
|
|
|
self.assertEquals(value,
|
|
|
|
xmlrpclib.loads(strg)[0][0])
|
|
|
|
self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,))
|
|
|
|
|
2001-10-01 14:47:44 -03:00
|
|
|
def test_main():
|
|
|
|
test_support.run_unittest(XMLRPCTestCase)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
test_main()
|