Example #1
0
 def test_loadFileArgsError(self):
     try:
         ujson.load("[]")
     except TypeError:
         pass
     else:
         assert False, "expected TypeError"
Example #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.assertEquals([1, 2, 3, 4], ujson.load(f))
     f = filelike()
     assert_array_equal(np.array([1, 2, 3, 4]), ujson.load(f, numpy=True))
Example #3
0
 def test_loadFile(self):
     f = StringIO.StringIO("[1,2,3,4]")
     self.assertEquals([1, 2, 3, 4], ujson.load(f))
     f = StringIO.StringIO("[1,2,3,4]")
     assert_array_equal(np.array([1, 2, 3, 4]), ujson.load(f, numpy=True))