FanFicFare/simplejson/tests/test_dump.py
Jim Miller 5ceb96c913 Adding WWOMB(www.squidge.org/peja) adapter. Some infrastructure changes to
allow config section [www.squidge.org/peja].  More needed to support other sites
under www.squidge.org.
2012-05-12 15:58:51 -05:00

21 lines
693 B
Python

from unittest import TestCase
from cStringIO import StringIO
import simplejson as json
class TestDump(TestCase):
def test_dump(self):
sio = StringIO()
json.dump({}, sio)
self.assertEquals(sio.getvalue(), '{}')
def test_dumps(self):
self.assertEquals(json.dumps({}), '{}')
def test_encode_truefalse(self):
self.assertEquals(json.dumps(
{True: False, False: True}, sort_keys=True),
'{"false": true, "true": false}')
self.assertEquals(json.dumps(
{2: 3.0, 4.0: 5L, False: 1, 6L: True, "7": 0}, sort_keys=True),
'{"false": 1, "2": 3.0, "4.0": 5, "6": true, "7": 0}')