Skip to content

Commit d71f649

Browse files
committed
Make zstd freethreaded compression test order independent
1 parent 0240ef4 commit d71f649

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Lib/test/test_zstd.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,15 +2675,17 @@ def test_compress_locking(self):
26752675

26762676
comp = ZstdCompressor()
26772677
parts = []
2678-
for _ in range(num_threads):
2678+
for _ in range(num_threads + 1):
26792679
res = comp.compress(input, ZstdCompressor.FLUSH_BLOCK)
26802680
if res:
26812681
parts.append(res)
26822682
rest1 = comp.flush()
26832683
expected = b''.join(parts) + rest1
26842684

26852685
comp = ZstdCompressor()
2686-
output = []
2686+
# Compress the first block to add the Zstandard header. This ensures
2687+
# that the parallel portion of the test is thread order independent.
2688+
output = [comp.compress(input, ZstdCompressor.FLUSH_BLOCK)]
26872689
def run_method(method, input_data, output_data):
26882690
res = method(input_data, ZstdCompressor.FLUSH_BLOCK)
26892691
if res:

0 commit comments

Comments
 (0)