コード例 #1
0
 def test_read_default_value(self):
     BYTES = 1024
     data_str = "*" * BYTES
     data = six.StringIO(data_str)
     reader = sizelimit.LimitingReader(data, BYTES)
     res = reader.read()
     self.assertEqual(data_str, res)
コード例 #2
0
 def _consume_all_read():
     bytes_read = 0
     data = six.StringIO("*" * BYTES)
     reader = sizelimit.LimitingReader(data, BYTES - 1)
     byte = reader.read(1)
     while len(byte) != 0:
         bytes_read += 1
         byte = reader.read(1)
コード例 #3
0
    def test_limiting_reader(self):
        BYTES = 1024
        bytes_read = 0
        data = six.StringIO("*" * BYTES)
        for chunk in sizelimit.LimitingReader(data, BYTES):
            bytes_read += len(chunk)

        self.assertEqual(BYTES, bytes_read)

        bytes_read = 0
        data = six.StringIO("*" * BYTES)
        reader = sizelimit.LimitingReader(data, BYTES)
        byte = reader.read(1)
        while len(byte) != 0:
            bytes_read += 1
            byte = reader.read(1)

        self.assertEqual(BYTES, bytes_read)
コード例 #4
0
 def _consume_all_iter():
     bytes_read = 0
     data = six.StringIO("*" * BYTES)
     for chunk in sizelimit.LimitingReader(data, BYTES - 1):
         bytes_read += len(chunk)