from unittest import TestCase
from io import StringIO

import 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: 5, False: 1, 6: True}, sort_keys=True),
                '{"false": 1, "2": 3.0, "4.0": 5, "6": true}')

[((133, 143), 'io.StringIO', 'StringIO', ([], {}), '()\n', (141, 143), False, 'from io import StringIO\n'), ((152, 170), 'json.dump', 'json.dump', (['{}', 'sio'], {}), '({}, sio)\n', (161, 170), False, 'import json\n'), ((272, 286), 'json.dumps', 'json.dumps', (['{}'], {}), '({})\n', (282, 286), False, 'import json\n'), ((358, 416), 'json.dumps', 'json.dumps', (['{(True): False, (False): True}'], {'sort_keys': '(True)'}), '({(True): False, (False): True}, sort_keys=True)\n', (368, 416), False, 'import json\n'), ((509, 580), 'json.dumps', 'json.dumps', (['{(2): 3.0, (4.0): 5, (False): 1, (6): True}'], {'sort_keys': '(True)'}), '({(2): 3.0, (4.0): 5, (False): 1, (6): True}, sort_keys=True)\n', (519, 580), False, 'import json\n')]