Пример #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'))