diff options
author | Sean McCully <sean.mccully@rackspace.com> | 2012-12-17 10:25:19 -0600 |
---|---|---|
committer | Sean McCully <sean.mccully@rackspace.com> | 2013-01-03 10:46:19 -0600 |
commit | e3ddc41f1b02644d7fae4482c4beade7f27e58de (patch) | |
tree | 95f2d9c6ea1b8dde6ba6fdce41ee1d75f929e8e3 /tests | |
parent | 91c9631bd3e3a0c72b36840ddf90e1db483f9a14 (diff) | |
download | oslo-e3ddc41f1b02644d7fae4482c4beade7f27e58de.tar.gz oslo-e3ddc41f1b02644d7fae4482c4beade7f27e58de.tar.xz oslo-e3ddc41f1b02644d7fae4482c4beade7f27e58de.zip |
JSONDictSerializer encode objects to unicode
Averts raising ValueError, Circular Reference Detected exception.
Add additional test to JSONDictSerializerTest testing that
JSONDictSerializer correctly serializes objects into unicode repr.
and not raise error
Fixes: bug #1089100
Change-Id: Ifdb0562c7c43ab66617dddb65f16f893df2f4895
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_wsgi.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unit/test_wsgi.py b/tests/unit/test_wsgi.py index 07c85d5..c621a8c 100644 --- a/tests/unit/test_wsgi.py +++ b/tests/unit/test_wsgi.py @@ -179,6 +179,17 @@ class JSONDictSerializerTest(unittest.TestCase): result = result.replace('\n', '').replace(' ', '') self.assertEqual(result, expected_json) + def test_object_unicode(self): + class TestUnicode: + def __unicode__(self): + return u'TestUnicode' + input_dict = dict(cls=TestUnicode()) + expected_str = '{"cls":"TestUnicode"}' + serializer = wsgi.JSONDictSerializer() + result = serializer.serialize(input_dict) + result = result.replace('\n', '').replace(' ', '') + self.assertEqual(result, expected_str) + class TextDeserializerTest(unittest.TestCase): |