Beispiel #1
0
 def test_dumpFileArgsError(self):
     try:
         ujson.dump([], '')
     except TypeError:
         pass
     else:
         assert False, 'expected TypeError'
Beispiel #2
0
 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)
Beispiel #3
0
 def test_dumpToFile(self):
     f = StringIO.StringIO()
     ujson.dump([1, 2, 3], f)
     self.assertEquals("[1,2,3]", f.getvalue())