def test_model_textio_compressed(self): temp_path = self.create_temp_file('aa\nbb\ncc') gzip_file_name = temp_path + '.gz' with open(temp_path) as src, gzip.open(gzip_file_name, 'wb') as dst: dst.writelines(src) # Add the temporary gzip file to be cleaned up as well. self.temp_files.append(gzip_file_name) snippets.model_textio_compressed({'read': gzip_file_name}, ['aa', 'bb', 'cc'])
def test_model_textio_compressed(self): temp_path = self.create_temp_file('aa\nbb\ncc') gzip_file_name = temp_path + '.gz' with open(temp_path) as src, gzip.open(gzip_file_name, 'wb') as dst: dst.writelines(src) # Add the temporary gzip file to be cleaned up as well. self.temp_files.append(gzip_file_name) snippets.model_textio_compressed( {'read': gzip_file_name}, ['aa', 'bb', 'cc'])
def test_model_textio_gzip_concatenated(self): temp_path_1 = self.create_temp_file('a\nb\nc\n') temp_path_2 = self.create_temp_file('p\nq\nr\n') temp_path_3 = self.create_temp_file('x\ny\nz') gzip_file_name = temp_path_1 + '.gz' with open(temp_path_1) as src, gzip.open(gzip_file_name, 'wb') as dst: dst.writelines(src) with open(temp_path_2) as src, gzip.open(gzip_file_name, 'ab') as dst: dst.writelines(src) with open(temp_path_3) as src, gzip.open(gzip_file_name, 'ab') as dst: dst.writelines(src) # Add the temporary gzip file to be cleaned up as well. self.temp_files.append(gzip_file_name) snippets.model_textio_compressed( {'read': gzip_file_name}, ['a', 'b', 'c', 'p', 'q', 'r', 'x', 'y', 'z'])
def test_model_textio_gzip_concatenated(self): temp_path_1 = self.create_temp_file('a\nb\nc\n') temp_path_2 = self.create_temp_file('p\nq\nr\n') temp_path_3 = self.create_temp_file('x\ny\nz') gzip_file_name = temp_path_1 + '.gz' with open(temp_path_1) as src, gzip.open(gzip_file_name, 'wb') as dst: dst.writelines(src) with open(temp_path_2) as src, gzip.open(gzip_file_name, 'ab') as dst: dst.writelines(src) with open(temp_path_3) as src, gzip.open(gzip_file_name, 'ab') as dst: dst.writelines(src) # Add the temporary gzip file to be cleaned up as well. self.temp_files.append(gzip_file_name) snippets.model_textio_compressed( {'read': gzip_file_name}, ['a', 'b', 'c', 'p', 'q', 'r', 'x', 'y', 'z'])