Skip to content

Commit e90c6a7

Browse files
committed
gh-145607: Reproduce flaky test_bz2.testDecompressorChunksMaxsize
Sort the glob results then shuffle with a fixed seed (555) so that the first bz2 block's compressed data extends into the last 64 bytes of BIG_DATA. The -64 truncation then yields an incomplete block, causing the assertFalse(bzd.needs_input) assertion to fail.
1 parent 1d091a3 commit e90c6a7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/test/test_bz2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class BaseTest(unittest.TestCase):
7272
# simply use the bigger test data for all tests.
7373
test_size = 0
7474
BIG_TEXT = bytearray(128*1024)
75-
for fname in glob.glob(os.path.join(glob.escape(os.path.dirname(__file__)), '*.py')):
75+
_files = sorted(glob.glob(os.path.join(glob.escape(os.path.dirname(__file__)), '*.py')))
76+
random.Random(555).shuffle(_files)
77+
for fname in _files:
7678
with open(fname, 'rb') as fh:
7779
test_size += fh.readinto(memoryview(BIG_TEXT)[test_size:])
7880
if test_size > 128*1024:

0 commit comments

Comments
 (0)