blob: c6feb9691a3d33dc248fc259114b15702fb4ea8a [file] [log] [blame]
Skip Montanaro3e7bba92001-10-19 16:06:52 +00001import sys
Skip Montanaro419abda2001-10-01 17:47:44 +00002import unittest
3import xmlrpclib
Barry Warsaw04f357c2002-07-23 19:04:11 +00004from test import test_support
Skip Montanaro419abda2001-10-01 17:47:44 +00005
6alist = [{'astring': 'foo@bar.baz.spam',
7 'afloat': 7283.43,
Skip Montanaro3e7bba92001-10-19 16:06:52 +00008 'anint': 2**20,
9 'ashortlong': 2L,
Skip Montanaro419abda2001-10-01 17:47:44 +000010 'anotherlist': ['.zyx.41'],
11 'abase64': xmlrpclib.Binary("my dog has fleas"),
12 'boolean': xmlrpclib.False,
13 }]
14
15class XMLRPCTestCase(unittest.TestCase):
16
17 def test_dump_load(self):
18 self.assertEquals(alist,
19 xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0])
20
Skip Montanaro3e7bba92001-10-19 16:06:52 +000021 def test_dump_big_long(self):
22 self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,))
23
24 def test_dump_bad_dict(self):
25 self.assertRaises(TypeError, xmlrpclib.dumps, ({(1,2,3): 1},))
26
27 def test_dump_big_int(self):
28 if sys.maxint > 2L**31-1:
29 self.assertRaises(OverflowError, xmlrpclib.dumps,
30 (int(2L**34),))
31
Skip Montanaro419abda2001-10-01 17:47:44 +000032def test_main():
33 test_support.run_unittest(XMLRPCTestCase)
34
35
36if __name__ == "__main__":
37 test_main()