summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_xmlrpc.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2005-02-10 18:33:30 (GMT)
committerFred Drake <fdrake@acm.org>2005-02-10 18:33:30 (GMT)
commitba613c3410c5a0ff547e43d2e9cdd9ffff1fca54 (patch)
treec58837f84f4915095cdf13393d0be4a0c7dcfdb4 /Lib/test/test_xmlrpc.py
parentbfd7d6a0eac396d80efe43fa4f03e056ac57f58d (diff)
downloadcpython-ba613c3410c5a0ff547e43d2e9cdd9ffff1fca54.zip
cpython-ba613c3410c5a0ff547e43d2e9cdd9ffff1fca54.tar.gz
cpython-ba613c3410c5a0ff547e43d2e9cdd9ffff1fca54.tar.bz2
accept datetime.datetime instances when marshalling;
dateTime.iso8601 elements still unmarshal into xmlrpclib.DateTime objects
Diffstat (limited to 'Lib/test/test_xmlrpc.py')
-rw-r--r--Lib/test/test_xmlrpc.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 1f533d2..8fa63de 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -1,3 +1,4 @@
+import datetime
import sys
import unittest
import xmlrpclib
@@ -12,6 +13,11 @@ alist = [{'astring': 'foo@bar.baz.spam',
'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 @@ class XMLRPCTestCase(unittest.TestCase):
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,))