예제 #1
0
 def _test_decompress(self, test_data):
     """This performs the same decompression tests as in the Python bindings of brotli reference implementation"""
     temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
     original = _test_utils.get_uncompressed_name(test_data)
     with open(temp_uncompressed, 'wb') as out_file:
         with open(test_data, 'rb') as in_file:
             out_file.write(decompress(in_file.read()))
     self.assertFilesMatch(temp_uncompressed, original)
예제 #2
0
 def _decompress_pipe(self, test_data):
     temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
     args = [PYTHON, BRO, '-d']
     with open(temp_uncompressed, 'wb') as out_file:
         with open(test_data, 'rb') as in_file:
             subprocess.check_call(args,
                                   stdin=in_file,
                                   stdout=out_file,
                                   env=TEST_ENV)
예제 #3
0
 def _check_decompression(self, test_data):
     # Write decompression to temp file and verify it matches the original.
     temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
     temp_compressed = _test_utils.get_temp_compressed_name(test_data)
     original = test_data
     with open(temp_uncompressed, 'wb') as out_file:
         with open(temp_compressed, 'rb') as in_file:
             out_file.write(brotli.decompress(in_file.read()))
     self.assertFilesMatch(temp_uncompressed, original)
예제 #4
0
 def _check_decompression(self, test_data, **kwargs):
     # Write decompression to temp file and verify it matches the original.
     temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
     temp_compressed = _test_utils.get_temp_compressed_name(test_data)
     original = test_data
     args = [PYTHON, BRO, '-f', '-d']
     if 'dictionary' in kwargs:
         args.extend(['--custom-dictionary', str(kwargs['dictionary'])])
     args.extend(['-i', temp_compressed, '-o', temp_uncompressed])
     subprocess.check_call(args, env=TEST_ENV)
     self.assertFilesMatch(temp_uncompressed, original)
예제 #5
0
 def _check_decompression(self, test_data, **kwargs):
     # Only dictionary is supported as a kwarg to brotli.decompress.
     if 'dictionary' in kwargs:
         kwargs = {'dictionary': kwargs['dictionary']}
     else:
         kwargs = {}
     # Write decompression to temp file and verify it matches the original.
     temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
     temp_compressed = _test_utils.get_temp_compressed_name(test_data)
     original = test_data
     with open(temp_uncompressed, 'wb') as out_file:
         with open(temp_compressed, 'rb') as in_file:
             out_file.write(brotli.decompress(in_file.read(), **kwargs))
     self.assertFilesMatch(temp_uncompressed, original)
예제 #6
0
 def _decompress_file(self, test_data):
     temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
     args = [
         PYTHON, BRO, '-f', '-d', '-i', test_data, '-o', temp_uncompressed
     ]
     subprocess.check_call(args, env=TEST_ENV)
예제 #7
0
 def _check_decompression(self, test_data):
     # Verify decompression matches the original.
     temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
     original = _get_original_name(test_data)
     self.assertFilesMatch(temp_uncompressed, original)
예제 #8
0
 def _decompress(self, test_data):
     temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
     with open(temp_uncompressed, 'wb') as out_file:
         with open(test_data, 'rb') as in_file:
             out_file.write(brotli.decompress(in_file.read()))