示例#1
0
 def __init__(self, source, allow_noop=False):
     if isinstance(source, unicode):
         source = source.encode('utf-8')
     if isinstance(source, bytes):
         source = BytesIO(source)
     self.read = source.read
     self.allow_noop = allow_noop
     self.dispatch = self.dispatch.copy()
示例#2
0
 def test_write_encoded_data_to_stream(self):
     stream = StringIO()
     self.encode((i for i in range(5)), stream)
     self.assertEqual(stream.getvalue(), b('[i\x00i\x01i\x02i\x03i\x04]'))
示例#3
0
 def test_write_encoded_data_to_stream(self):
     stream = StringIO()
     self.encode((i for i in range(5)), stream)
     self.assertEqual(stream.getvalue(),
                      b('[i\x00i\x01i\x02i\x03i\x04]'))
示例#4
0
 def test_write_encoded_data_to_stream(self):
     stream = StringIO()
     self.encode((i for i in range(5)), stream)
     self.assertEqual(stream.getvalue(),
                      b('a\xffB\x00B\x01B\x02B\x03B\x04E'))