diff options
author | Russell Bryant <rbryant@redhat.com> | 2012-07-16 10:30:25 -0400 |
---|---|---|
committer | Russell Bryant <rbryant@redhat.com> | 2012-07-16 10:30:25 -0400 |
commit | 12575344308fee5f04af9586c683e0814f171991 (patch) | |
tree | b30ebedea363a7b13a1f73e0813b24895069a823 /tests/unit/test_jsonutils.py | |
parent | 9f708c0eff284d86c76b4c3b093841c3c4538cd5 (diff) | |
download | oslo-serialization-12575344308fee5f04af9586c683e0814f171991.tar.gz |
Use strtime() in to_primitive() for datetime objs.
This patch updates jsonutils.to_primitive() to use timeutils.strtime()
to convert a datimetime object to a string instead of just using str().
This ensures that we can easily convert the string back to a datetime
using timeutils.parse_strtime().
Required for the nova blueprint no-db-messaging.
Change-Id: I725b333695930e12e2832378102514326fec639c
Diffstat (limited to 'tests/unit/test_jsonutils.py')
-rw-r--r-- | tests/unit/test_jsonutils.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/unit/test_jsonutils.py b/tests/unit/test_jsonutils.py index 9b987cd..4a18b77 100644 --- a/tests/unit/test_jsonutils.py +++ b/tests/unit/test_jsonutils.py @@ -54,15 +54,15 @@ class ToPrimitiveTestCase(unittest.TestCase): self.assertEquals(jsonutils.to_primitive({}), {}) def test_datetime(self): - x = datetime.datetime(1, 2, 3, 4, 5, 6, 7) + x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7) self.assertEquals(jsonutils.to_primitive(x), - "0001-02-03 04:05:06.000007") + '1920-02-03T04: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") + '1971-02-03T04:05:06.000000') def test_iter(self): class IterClass(object): |