[Python-checkins] python/dist/src/Lib/test test_xmlrpc.py,1.5,1.6

fdrake at users.sourceforge.net fdrake at users.sourceforge.net
Thu Feb 10 19:33:32 CET 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18795/Lib/test

Modified Files:
	test_xmlrpc.py 
Log Message:
accept datetime.datetime instances when marshalling;
dateTime.iso8601 elements still unmarshal into xmlrpclib.DateTime objects


Index: test_xmlrpc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_xmlrpc.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- test_xmlrpc.py	5 Jun 2004 12:33:27 -0000	1.5
+++ test_xmlrpc.py	10 Feb 2005 18:33:30 -0000	1.6
@@ -1,3 +1,4 @@
+import datetime
 import sys
 import unittest
 import xmlrpclib
@@ -12,6 +13,11 @@
           'boolean': xmlrpclib.False,
           'unicode': u'\u4000\u6000\u8000',
           u'ukey\u4000': 'regular value',
+          'datetime1': xmlrpclib.DateTime('20050210T11:41:23'),
+          'datetime2': xmlrpclib.DateTime(
+                        (2005, 02, 10, 11, 41, 23, 0, 1, -1)),
+          'datetime3': xmlrpclib.DateTime(
+                        datetime.datetime(2005, 02, 10, 11, 41, 23)),
           }]
 
 class XMLRPCTestCase(unittest.TestCase):
@@ -20,6 +26,17 @@
         self.assertEquals(alist,
                           xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0])
 
+    def test_dump_bare_datetime(self):
+        # This checks that an unwrapped datetime object can be handled
+        # by the marshalling code.  This can't be done via
+        # test_dump_load() since the unmarshaller doesn't produce base
+        # datetime instances.
+        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
+        s = xmlrpclib.dumps((dt,))
+        r, m = xmlrpclib.loads(s)
+        self.assertEquals(r, (xmlrpclib.DateTime('20050210T11:41:23'),))
+        self.assertEquals(m, None)
+
     def test_dump_big_long(self):
         self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,))
 



More information about the Python-checkins mailing list