Example #1
0
 def check_decompression(self, compress_ext, compress_func):
     test_text = 'decompression\ntest\n'
     test_data = compress_func(test_text)
     stream = tutil.MockStreamReader('.', test_data)
     reader = StreamFileReader(stream, [Range(0, 0, len(test_data))],
                               'test.' + compress_ext)
     self.assertEqual(test_text, ''.join(reader.readall_decompressed()))
Example #2
0
 def make_count_reader(self):
     stream = tutil.MockStreamReader('.', '01234', '34567', '67890')
     return StreamFileReader(
         stream,
         [Range(1, 0, 3), Range(6, 3, 3),
          Range(11, 6, 3)], 'count.txt')
Example #3
0
 def test_name_attribute(self):
     # Test both .name and .name() (for backward compatibility)
     stream = tutil.MockStreamReader()
     sfile = StreamFileReader(stream, [Range(0, 0, 0)], 'nametest')
     self.assertEqual('nametest', sfile.name)
     self.assertEqual('nametest', sfile.name())
Example #4
0
 def check_decompressed_name(self, filename, expect):
     stream = tutil.MockStreamReader('.', '')
     reader = StreamFileReader(stream, [Range(0, 0, 0)], filename)
     self.assertEqual(expect, reader.decompressed_name())
Example #5
0
 def make_newlines_reader(self):
     stream = tutil.MockStreamReader('.', 'one\ntwo\n\nth', 'ree\nfour\n\n')
     return StreamFileReader(
         stream, [Range(0, 0, 11), Range(11, 11, 10)], 'count.txt')