summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Roelandt <cyril.roelandt@enovance.com>2014-03-13 20:00:20 +0100
committerCyril Roelandt <cyril.roelandt@enovance.com>2014-03-13 20:00:20 +0100
commit659c3aaf2891b17aa01357d4aeab39255ef87dbc (patch)
tree08bec659231c1cdb86d02306234801973111e0d6
parentad48c40528c67639a1b57d0b89b42ccf76954ae1 (diff)
downloadoslo-serialization-659c3aaf2891b17aa01357d4aeab39255ef87dbc.tar.gz
Python3: enable test_jsonutils.py
Change-Id: I22f5d92c4c0034162b6fc27b785bd034d4d25f86 Blueprint: make-python3-compatible
-rw-r--r--tests/unit/test_jsonutils.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/unit/test_jsonutils.py b/tests/unit/test_jsonutils.py
index 9eb0538..5ab04ed 100644
--- a/tests/unit/test_jsonutils.py
+++ b/tests/unit/test_jsonutils.py
@@ -83,6 +83,7 @@ class ToPrimitiveTestCase(test.BaseTestCase):
raise StopIteration
self.index = self.index + 1
return self.data[self.index - 1]
+ __next__ = next
x = IterClass()
self.assertEqual(jsonutils.to_primitive(x), [1, 2, 3, 4, 5])
@@ -133,7 +134,10 @@ class ToPrimitiveTestCase(test.BaseTestCase):
def test_typeerror(self):
x = bytearray # Class, not instance
- self.assertEqual(jsonutils.to_primitive(x), u"<type 'bytearray'>")
+ if six.PY3:
+ self.assertEqual(jsonutils.to_primitive(x), u"<class 'bytearray'>")
+ else:
+ self.assertEqual(jsonutils.to_primitive(x), u"<type 'bytearray'>")
def test_nasties(self):
def foo():
@@ -142,7 +146,12 @@ class ToPrimitiveTestCase(test.BaseTestCase):
ret = jsonutils.to_primitive(x)
self.assertEqual(len(ret), 3)
self.assertTrue(ret[0].startswith(u"<module 'datetime' from "))
- self.assertTrue(ret[1].startswith('<function foo at 0x'))
+ if six.PY3:
+ self.assertTrue(ret[1].startswith('<function '
+ 'ToPrimitiveTestCase.test_nasties.<locals>.foo '
+ 'at 0x'))
+ else:
+ self.assertTrue(ret[1].startswith('<function foo at 0x'))
self.assertEqual(ret[2], '<built-in function dir>')
def test_depth(self):