Skip to content

Commit 0a24e10

Browse files
committed
Increase threshold for zipfile test_many_opens
It turns out that there are many other tests that can impact test_many_opens by leaving unclosed file handles. Rather than fix them all, it is easier to simply increase the threshold for the problematic test.
1 parent e6c7388 commit 0a24e10

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎Lib/test/test_zipfile.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,17 +2561,22 @@ def test_write_after_read(self):
25612561
self.assertEqual(data1, self.data1)
25622562
self.assertEqual(data2, self.data2)
25632563

2564+
# TODO: RUSTPYTHON other tests can impact the file descriptor incrementor
2565+
# by leaving file handles unclosed. If there are more than 100 files in
2566+
# TESTFN and references to them are left unclosed and ungarbage collected
2567+
# in another test, then fileno() will always be too high for this test to
2568+
# pass. The solution is to increase the number of files from 100 to 200
25642569
def test_many_opens(self):
25652570
# Verify that read() and open() promptly close the file descriptor,
25662571
# and don't rely on the garbage collector to free resources.
25672572
self.make_test_archive(TESTFN2)
25682573
with zipfile.ZipFile(TESTFN2, mode="r") as zipf:
2569-
for x in range(100):
2574+
for x in range(200):
25702575
zipf.read('ones')
25712576
with zipf.open('ones') as zopen1:
25722577
pass
25732578
with open(os.devnull, "rb") as f:
2574-
self.assertLess(f.fileno(), 100)
2579+
self.assertLess(f.fileno(), 200)
25752580

25762581
def test_write_while_reading(self):
25772582
with zipfile.ZipFile(TESTFN2, 'w', zipfile.ZIP_DEFLATED) as zipf:

0 commit comments

Comments
 (0)