mirror of
https://github.com/google/brotli.git
synced 2024-11-22 11:40:06 +00:00
1e5ea6aedd
Also - rename `test_utils` to `_test_utils` - refactor shared code into `_test_utils`
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
# Copyright 2016 The Brotli Authors. All rights reserved.
|
|
#
|
|
# Distributed under MIT license.
|
|
# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
|
|
import unittest
|
|
|
|
import _test_utils
|
|
import brotli
|
|
|
|
|
|
def _get_original_name(test_data):
|
|
return test_data.split('.compressed')[0]
|
|
|
|
|
|
class TestDecompress(_test_utils.TestCase):
|
|
|
|
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)
|
|
|
|
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()))
|
|
|
|
def _test_decompress(self, test_data):
|
|
self._decompress(test_data)
|
|
self._check_decompression(test_data)
|
|
|
|
|
|
_test_utils.generate_test_methods(TestDecompress, for_decompression=True)
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|