예제 #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())
예제 #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))
예제 #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())
예제 #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())
예제 #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')
예제 #6
0
 def test_compressed_readall(self):
     data = BytesIO(compress(b'foo'))
     with CompressedStreamReader(data) as reader:
         self.assertEqual(reader.read(), b'foo')
예제 #7
0
 def test_empty_compressed_stream(self):
     data = BytesIO(compress(b''))
     with CompressedStreamReader(data) as reader:
         self.assertEqual(reader.read(), b'')
예제 #8
0
 def test_empty_stream(self):
     data = BytesIO(b'')
     with CompressedStreamReader(data) as reader:
         reader.read()