Beispiel #1
0
 def test_loadFileArgsError(self):
     try:
         ultrajson.load("[]")
     except TypeError:
         pass
     else:
         assert False, "expected TypeError"
Beispiel #2
0
 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))
Beispiel #3
0
    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
Beispiel #4
0
 def test_loadFile(self):
     f = StringIO("[1,2,3,4]")
     self.assertEqual([1, 2, 3, 4], ultrajson.load(f))