def test_dumpFileArgsError(self): try: ujson.dump([], '') except TypeError: pass else: assert False, 'expected TypeError'
def test_dumpToFileLikeObject(self): class filelike: def __init__(self): self.bytes = '' def write(self, bytes): self.bytes += bytes f = filelike() ujson.dump([1, 2, 3], f) self.assertEquals("[1,2,3]", f.bytes)
def test_dumpToFile(self): f = StringIO.StringIO() ujson.dump([1, 2, 3], f) self.assertEquals("[1,2,3]", f.getvalue())