mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Try to get rid of spurious failure in test_resource on the Debian buildbots by changing the file size limit before attempting to close the file
This commit is contained in:
parent
13c25c08ca
commit
12adef9b8b
1 changed files with 16 additions and 9 deletions
|
@ -49,17 +49,24 @@ class ResourceTest(unittest.TestCase):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
limit_set = False
|
limit_set = False
|
||||||
f = open(test_support.TESTFN, "wb")
|
f = open(test_support.TESTFN, "wb")
|
||||||
f.write("X" * 1024)
|
|
||||||
try:
|
try:
|
||||||
f.write("Y")
|
f.write("X" * 1024)
|
||||||
f.flush()
|
try:
|
||||||
except IOError:
|
f.write("Y")
|
||||||
if not limit_set:
|
f.flush()
|
||||||
raise
|
except IOError:
|
||||||
f.close()
|
if not limit_set:
|
||||||
os.unlink(test_support.TESTFN)
|
raise
|
||||||
|
if limit_set:
|
||||||
|
# Close will attempt to flush the byte we wrote
|
||||||
|
# Restore limit first to avoid getting a spurious error
|
||||||
|
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
os.unlink(test_support.TESTFN)
|
||||||
finally:
|
finally:
|
||||||
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
|
if limit_set:
|
||||||
|
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
|
||||||
|
|
||||||
def test_fsize_toobig(self):
|
def test_fsize_toobig(self):
|
||||||
# Be sure that setrlimit is checking for really large values
|
# Be sure that setrlimit is checking for really large values
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue