Skip to content

Commit 7be6308

Browse files
authored
Merge pull request RustPython#5206 from dchiquito/fix-test-zipfile
Increase threshold for zipfile test_many_opens
2 parents 02cec85 + 0a24e10 commit 7be6308

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎Lib/test/test_os.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4248,9 +4248,8 @@ def assert_stat_equal(self, stat1, stat2, skip_fields):
42484248
else:
42494249
self.assertEqual(stat1, stat2)
42504250

4251-
# TODO: RUSTPPYTHON (AssertionError: TypeError not raised by ScandirIter)
4252-
# TODO: See https://github.com/RustPython/RustPython/issues/5190 for skip rationale
4253-
@unittest.skip("skipping to avoid the unclosed scandir from squatting on file descriptors")
4251+
# TODO: RUSTPYTHON (AssertionError: TypeError not raised by ScandirIter)
4252+
@unittest.expectedFailure
42544253
def test_uninstantiable(self):
42554254
scandir_iter = os.scandir(self.path)
42564255
self.assertRaises(TypeError, type(scandir_iter))

‎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)