Support zstd compression via the Python 3.14 compression module
Map --compression values to the compression package submodules so zstd is available alongside gzip, lzma and bz2. Default remains gzip.
This commit is contained in:
parent
5e0fd54a92
commit
33b08d3a09
3 changed files with 30 additions and 3 deletions
|
|
@ -1,7 +1,9 @@
|
|||
|
||||
import contextlib
|
||||
import os
|
||||
import pickle
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
import unittest.mock
|
||||
|
||||
|
|
@ -158,5 +160,25 @@ class LruCacheWithEvictionTestCase(unittest.TestCase):
|
|||
self._assert_cache(a, 1, 2, 2)
|
||||
|
||||
|
||||
class CompressionTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.temp_dir = tempfile.mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.temp_dir)
|
||||
|
||||
def test_open_funcs_round_trip(self):
|
||||
value = {"text": list(range(1000))}
|
||||
for compression in ["gzip", "lzma", "bz2", "zstd", "none"]:
|
||||
with self.subTest(compression=compression):
|
||||
open_func = tools.compression_open_func(compression)
|
||||
path = os.path.join(self.temp_dir, f"cache.{compression}")
|
||||
with open_func(path, "wb") as cache_file:
|
||||
pickle.dump(value, cache_file)
|
||||
with open_func(path, "rb") as cache_file:
|
||||
self.assertEqual(pickle.load(cache_file), value)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
golden.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue