From d71f649214aea0d92a5656b26567cee5a764477a Mon Sep 17 00:00:00 2001 From: Emma Harper Smith Date: Mon, 7 Jul 2025 18:27:29 -0700 Subject: [PATCH] Make zstd freethreaded compression test order independent --- Lib/test/test_zstd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_zstd.py b/Lib/test/test_zstd.py index 90b2adc9665480..9e0d00043d9b0c 100644 --- a/Lib/test/test_zstd.py +++ b/Lib/test/test_zstd.py @@ -2675,7 +2675,7 @@ def test_compress_locking(self): comp = ZstdCompressor() parts = [] - for _ in range(num_threads): + for _ in range(num_threads + 1): res = comp.compress(input, ZstdCompressor.FLUSH_BLOCK) if res: parts.append(res) @@ -2683,7 +2683,9 @@ def test_compress_locking(self): expected = b''.join(parts) + rest1 comp = ZstdCompressor() - output = [] + # Compress the first block to add the Zstandard header. This ensures + # that the parallel portion of the test is thread order independent. + output = [comp.compress(input, ZstdCompressor.FLUSH_BLOCK)] def run_method(method, input_data, output_data): res = method(input_data, ZstdCompressor.FLUSH_BLOCK) if res: