Exemple #1
0
 def wu_helper(self, data):
     out_stream = StringIO()
     for x in data:
         if isinstance(x, int):
             srl.serialize_vint(x, out_stream)
         elif isinstance(x, basestring):
             wu.writeString(out_stream, x)
     return out_stream.getvalue()
 def wu_helper(self, data):
     out_stream = StringIO()
     for x in data:
         if isinstance(x, int):
             srl.serialize_vint(x, out_stream)
         elif isinstance(x, basestring):
             wu.writeString(out_stream, x)
     return out_stream.getvalue()
Exemple #3
0
 def test_simulate_java_output_1(self):
     try:
         byte_stream = _get_java_output_stream(self.wd)
         out_stream = StringIO()
         # write integers
         srl.serialize_vint(42, out_stream)
         srl.serialize_vint(4242, out_stream)
         srl.serialize_vint(424242, out_stream)
         srl.serialize_vint(42424242, out_stream)
         srl.serialize_vint(-42, out_stream)
         # write longs
         srl.serialize_vint(42, out_stream)
         srl.serialize_vint(424242, out_stream)
         srl.serialize_vint(4242424242, out_stream)
         # strings
         wu.writeString(out_stream, u"hello world")
         # second has accented characters
         wu.writeString(out_stream, u"oggi è giovedì")
         #
         srl.serialize_text(u"à Text object", out_stream)
         self.assertEqual(byte_stream.getvalue(), out_stream.getvalue())
     finally:
         pass
 def test_simulate_java_output_1(self):
     try:
         byte_stream = _get_java_output_stream(self.wd)
         out_stream = StringIO()
         # write integers
         srl.serialize_vint(42, out_stream)
         srl.serialize_vint(4242, out_stream)
         srl.serialize_vint(424242, out_stream)
         srl.serialize_vint(42424242, out_stream)
         srl.serialize_vint(-42, out_stream)
         # write longs
         srl.serialize_vint(42, out_stream)
         srl.serialize_vint(424242, out_stream)
         srl.serialize_vint(4242424242, out_stream)
         # strings
         wu.writeString(out_stream, u"hello world")
         # second has accented characters
         wu.writeString(out_stream, u"oggi è giovedì")
         #
         srl.serialize_text(u"à Text object", out_stream)
         self.assertEqual(byte_stream.getvalue(), out_stream.getvalue())
     finally:
         pass
Exemple #5
0
 def test_wu_nonascii_string(self):
     # test for self-consistency
     wu.writeString(self.stream, u"àéìòù")
     self.stream.seek(0)
     self.assertEqual(u"àéìòù", wu.readString(self.stream))
Exemple #6
0
 def test_wu_ascii_string(self):
     # test for self-consistency
     wu.writeString(self.stream, "simple")
     self.stream.seek(0)
     self.assertEqual(u"simple", wu.readString(self.stream))
Exemple #7
0
 def test_wu_nonascii_string(self):
     # test for self-consistency
     wu.writeString(self.stream, u"àéìòù")
     self.stream.seek(0)
     self.assertEqual(u"àéìòù", wu.readString(self.stream))
Exemple #8
0
 def test_wu_ascii_string(self):
     # test for self-consistency
     wu.writeString(self.stream, "simple")
     self.stream.seek(0)
     self.assertEqual(u"simple", wu.readString(self.stream))