Exemplo n.º 1
0
 def test_questions(self):
     data = BytesIO(compress(b''))
     with CompressedStreamReader(data) as reader:
         self.assertTrue(reader.readable())
         self.assertFalse(reader.writable())
         self.assertFalse(reader.seekable())
Exemplo n.º 2
0
 def test_small_buffer(self):
     data = BytesIO(compress(b'abcdefghijklmnopqrstuvwxyz'))
     with CompressedStreamReader(data, 1) as reader:
         self.assertEqual(b'abcd', reader.read(4))
Exemplo n.º 3
0
 def test_broken_compression(self):
     data = BytesIO(b'1234567890')
     with self.assertRaises(zlib.error):
         with CompressedStreamReader(data, 4) as reader:
             self.assertEqual(b'', reader.read(6))
     self.assertEqual(0, data.tell())
Exemplo n.º 4
0
 def test_uncompressed_tail(self):
     data = BytesIO(compress(b'foo')+b'bar')
     with CompressedStreamReader(data) as reader:
         self.assertEqual(b'foo', reader.read())
     self.assertEqual(b'bar', data.read())
Exemplo n.º 5
0
 def test_compressed_readline(self):
     data = BytesIO(compress(b'foo\nbar\n'))
     with CompressedStreamReader(data) as reader:
         self.assertEqual(reader.readline(), b'foo\n')
         self.assertEqual(reader.readline(), b'bar\n')
Exemplo n.º 6
0
 def test_compressed_readall(self):
     data = BytesIO(compress(b'foo'))
     with CompressedStreamReader(data) as reader:
         self.assertEqual(reader.read(), b'foo')
Exemplo n.º 7
0
 def test_empty_compressed_stream(self):
     data = BytesIO(compress(b''))
     with CompressedStreamReader(data) as reader:
         self.assertEqual(reader.read(), b'')
Exemplo n.º 8
0
 def test_empty_stream(self):
     data = BytesIO(b'')
     with CompressedStreamReader(data) as reader:
         reader.read()