cpython/Lib/test/test_json/test_default.py

24 lines
647 B
Python
Raw Normal View History

import collections
from test.test_json import PyTest, CTest
2011-05-14 00:47:51 -03:00
class TestDefault:
def test_default(self):
self.assertEqual(
2011-05-14 00:47:51 -03:00
self.dumps(type, default=repr),
self.dumps(repr(type)))
def test_ordereddict(self):
od = collections.OrderedDict(a=1, b=2, c=3, d=4)
od.move_to_end('b')
self.assertEqual(
self.dumps(od),
'{"a": 1, "c": 3, "d": 4, "b": 2}')
self.assertEqual(
self.dumps(od, sort_keys=True),
'{"a": 1, "b": 2, "c": 3, "d": 4}')
2011-05-14 00:47:51 -03:00
class TestPyDefault(TestDefault, PyTest): pass
class TestCDefault(TestDefault, CTest): pass