0001 import sys 0002 import unittest 0003 import xmlrpclib 0004 from test import test_support 0005 0006 alist = [{'astring': 'foo@bar.baz.spam', 0007 'afloat': 7283.43, 0008 'anint': 2**20, 0009 'ashortlong': 2L, 0010 'anotherlist': ['.zyx.41'], 0011 'abase64': xmlrpclib.Binary("my dog has fleas"), 0012 'boolean': xmlrpclib.False, 0013 'unicode': u'\u4000\u6000\u8000', 0014 u'ukey\u4000': 'regular value', 0015 }] 0016 0017 class XMLRPCTestCase(unittest.TestCase): 0018 0019 def test_dump_load(self): 0020 self.assertEquals(alist, 0021 xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0]) 0022 0023 def test_dump_big_long(self): 0024 self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,)) 0025 0026 def test_dump_bad_dict(self): 0027 self.assertRaises(TypeError, xmlrpclib.dumps, ({(1,2,3): 1},)) 0028 0029 def test_dump_big_int(self): 0030 if sys.maxint > 2L**31-1: 0031 self.assertRaises(OverflowError, xmlrpclib.dumps, 0032 (int(2L**34),)) 0033 0034 def test_dump_none(self): 0035 value = alist + [None] 0036 arg1 = (alist + [None],) 0037 strg = xmlrpclib.dumps(arg1, allow_none=True) 0038 self.assertEquals(value, 0039 xmlrpclib.loads(strg)[0][0]) 0040 self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,)) 0041 0042 def test_main(): 0043 test_support.run_unittest(XMLRPCTestCase) 0044 0045 0046 if __name__ == "__main__": 0047 test_main() 0048
Generated by PyXR 0.9.4