def test_read_compressed_write_compressed(self): gzfs = GzipFileStream(self.gz_path, 'rb') out = GzipFileStream(self.test_path, 'w') for line in gzfs: out.write(line) out.close() gzfs.close() self.assertTrue(is_gzipped(self.test_path)) self.assertSameFiles([self.gz_path, self.test_path], exclude_line_endings=True)
def test_write_compressed_file(self): fs, close = process_file_arg(self.ungz_path, 'rb') out, close_out = process_file_arg(self.test_path, 'wb', compresslevel=9) for line in fs: out.write(line) if close_out: out.close() if close: fs.close() self.assertTrue(is_gzipped(self.test_path)) self.assertSameFiles([self.gz_path, self.test_path], exclude_line_endings=True)
def test_simple(self): self.assertFalse(is_gzipped(self.cfg_path)) self.assertTrue(is_gzipped(self.gz_path))