Skip Montanaro | 3e7bba9 | 2001-10-19 16:06:52 +0000 | [diff] [blame] | 1 | import sys |
Skip Montanaro | 419abda | 2001-10-01 17:47:44 +0000 | [diff] [blame] | 2 | import unittest |
| 3 | import xmlrpclib |
Barry Warsaw | 04f357c | 2002-07-23 19:04:11 +0000 | [diff] [blame] | 4 | from test import test_support |
Skip Montanaro | 419abda | 2001-10-01 17:47:44 +0000 | [diff] [blame] | 5 | |
| 6 | alist = [{'astring': 'foo@bar.baz.spam', |
| 7 | 'afloat': 7283.43, |
Skip Montanaro | 3e7bba9 | 2001-10-19 16:06:52 +0000 | [diff] [blame] | 8 | 'anint': 2**20, |
| 9 | 'ashortlong': 2L, |
Skip Montanaro | 419abda | 2001-10-01 17:47:44 +0000 | [diff] [blame] | 10 | 'anotherlist': ['.zyx.41'], |
| 11 | 'abase64': xmlrpclib.Binary("my dog has fleas"), |
| 12 | 'boolean': xmlrpclib.False, |
| 13 | }] |
| 14 | |
| 15 | class XMLRPCTestCase(unittest.TestCase): |
| 16 | |
| 17 | def test_dump_load(self): |
| 18 | self.assertEquals(alist, |
| 19 | xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0]) |
| 20 | |
Skip Montanaro | 3e7bba9 | 2001-10-19 16:06:52 +0000 | [diff] [blame] | 21 | 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 Montanaro | 419abda | 2001-10-01 17:47:44 +0000 | [diff] [blame] | 32 | def test_main(): |
| 33 | test_support.run_unittest(XMLRPCTestCase) |
| 34 | |
| 35 | |
| 36 | if __name__ == "__main__": |
| 37 | test_main() |