From e70d40953b875a6bc8588b0ab0b964aea70ce301 Mon Sep 17 00:00:00 2001 From: Naman Date: Wed, 7 Oct 2026 07:50:05 +0530 Subject: [PATCH 1/4] Fix decompression CLI format detection --- src/snappy/__main__.py | 3 +-- test_formats.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/snappy/__main__.py b/src/snappy/__main__.py index 07c95f7..507da48 100644 --- a/src/snappy/__main__.py +++ b/src/snappy/__main__.py @@ -76,13 +76,12 @@ def cmdline_main(): method = formats.get_compress_function(args.target_format) else: try: - method, read_chunk = formats.get_decompress_function( + method = formats.get_decompress_function( args.target_format, args.infile ) except UncompressError as err: sys.exit("Failed to get decompress function: {}".format(err)) - additional_args['start_chunk'] = read_chunk method(args.infile, args.outfile, **additional_args) diff --git a/test_formats.py b/test_formats.py index 6453b1e..66615b7 100644 --- a/test_formats.py +++ b/test_formats.py @@ -71,6 +71,26 @@ class TestFormatRawAuto(TestFormatBase): decompress_format = "auto" success = True +class TestDecompressFunction(TestCase): + def test_auto_returns_function(self): + data = b"hello world" + + compressed = io.BytesIO() + formats.get_compress_function("auto")( + io.BytesIO(data), + compressed + ) + compressed.seek(0) + + decompress_func = formats.get_decompress_function( + "auto", + compressed + ) + + decompressed = io.BytesIO() + decompress_func(compressed, decompressed) + + self.assertEqual(data, decompressed.getvalue()) if __name__ == "__main__": import unittest From 34045beed0314801addf3fe72960f28ed60ea243 Mon Sep 17 00:00:00 2001 From: Naman Date: Wed, 7 Oct 2026 07:56:47 +0530 Subject: [PATCH 2/4] Add CLI decompression regression test --- test_formats.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/test_formats.py b/test_formats.py index 66615b7..3e65a38 100644 --- a/test_formats.py +++ b/test_formats.py @@ -1,7 +1,9 @@ import io import os from unittest import TestCase - +import subprocess +import sys +import tempfile from snappy import snappy_formats as formats @@ -92,6 +94,38 @@ def test_auto_returns_function(self): self.assertEqual(data, decompressed.getvalue()) + def test_cli_decompress(self): + data = b"hello world" + + with tempfile.TemporaryDirectory() as tmpdir: + compressed = os.path.join(tmpdir, "input.snappy") + output = os.path.join(tmpdir, "output.txt") + + with open(compressed, "wb") as f: + formats.get_compress_function("auto")( + io.BytesIO(data), + f + ) + + result = subprocess.run( + [ + sys.executable, + "-m", + "snappy", + "-d", + compressed, + output, + ], + capture_output=True, + text=True, + ) + + self.assertEqual(result.returncode, 0) + + with open(output, "rb") as f: + self.assertEqual(data, f.read()) + + if __name__ == "__main__": import unittest unittest.main() From 2288061b79a85bc30b43f6317057934648d3d34b Mon Sep 17 00:00:00 2001 From: Naman Date: Thu, 8 Oct 2026 10:59:24 +0530 Subject: [PATCH 3/4] Fix sdist filename in CI workflow --- .github/workflows/wheel.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index f36ea56..b217c4e 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -35,7 +35,7 @@ jobs: run: python setup.py sdist - name: Install python-snappy sdist - run: pip install dist/python-snappy*.tar.gz + run: pip install dist/python_snappy*.tar.gz - name: Pytest run: pytest --verbose test_snappy.py @@ -44,7 +44,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: wheels - path: dist/python-snappy*.tar.gz + path: dist/python_snappy*.tar.gz build: runs-on: ${{ matrix.os }} From f84ebdea866be0e309f54ed82109c0ca7754f295 Mon Sep 17 00:00:00 2001 From: Naman Date: Sat, 10 Oct 2026 06:27:15 +0530 Subject: [PATCH 4/4] Update deprecated GitHub Actions runners --- .github/workflows/wheel.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index b217c4e..2cf7eff 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -51,19 +51,19 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, macos-12, windows-2019] + os: [ubuntu-22.04, macos-14, windows-2022] architecture: ["x64"] linux_archs: ["auto s390x"] include: - - os: windows-2019 + - os: windows-2022 architecture: "x86" skip: "*2*win* *win_amd64" environment_windows: INCLUDE="C:/Program Files (x86)/Snappy/include" LIB="C:/Program Files (x86)/Snappy/lib" - - os: windows-2019 + - os: windows-2022 architecture: "x64" skip: "*2*win* *win32" environment_windows: INCLUDE="C:/Program Files/Snappy/include" LIB="C:/Program Files/Snappy/lib" - - os: ubuntu-20.04 + - os: ubuntu-22.04 architecture: "x64" linux_archs: aarch64 ppc64le