def test_loadFileArgsError(self): try: ultrajson.load("[]") except TypeError: pass else: assert False, "expected TypeError"
def test_loadFileLikeObject(self): class filelike: def read(self): try: self.end except AttributeError: self.end = True return "[1,2,3,4]" f = filelike() self.assertEqual([1, 2, 3, 4], ultrajson.load(f))
def read_corpus(self, file_name): """ Read and return the data from a corpus json file. """ # import simplejson as json # import json # ultrajson is much faster for handling large files import ultrajson as json with open(file_name) as data_file: data = json.load(data_file) return data
def test_loadFile(self): f = StringIO("[1,2,3,4]") self.assertEqual([1, 2, 3, 4], ultrajson.load(f))