diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-06-07 23:22:17 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-06-07 23:23:37 +0000 |
| commit | 8dbf60c81ba89f578f035e871bde622804053f54 (patch) | |
| tree | b6fddd7e719c08141bab7955bf25a1d3ae6a4f65 /tests/unit/test_jsonutils.py | |
| parent | 3f0df42daeb0229a1c04382ee8973f9b32e9de4b (diff) | |
Handle xmlrpclib.DateTime types when serializing to JSON
Fixes bug 1010124
Convert xmlrpclib.DateTime types to datetime so they can be serialized
without creating an exception.
Change-Id: Ifcab69ad81d39d7f4066df5c71c6ab6734fb1fab
Diffstat (limited to 'tests/unit/test_jsonutils.py')
| -rw-r--r-- | tests/unit/test_jsonutils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/unit/test_jsonutils.py b/tests/unit/test_jsonutils.py index 084a172..5764f45 100644 --- a/tests/unit/test_jsonutils.py +++ b/tests/unit/test_jsonutils.py @@ -17,6 +17,7 @@ import datetime import unittest +import xmlrpclib from openstack.common import jsonutils @@ -52,6 +53,12 @@ class ToPrimitiveTestCase(unittest.TestCase): self.assertEquals(jsonutils.to_primitive(x), "0001-02-03 04:05:06.000007") + def test_DateTime(self): + x = xmlrpclib.DateTime() + x.decode("19710203T04:05:06") + self.assertEquals(jsonutils.to_primitive(x), + "1971-02-03 04:05:06") + def test_iter(self): class IterClass(object): def __init__(self): |
