diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2007-07-24 14:39:23 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2007-07-24 14:39:23 (GMT) |
commit | 12adef9b8b44f0535cfb5c30437541ef67327b17 (patch) | |
tree | 4d4d93a656c3610b58629f1cf7a65a7c74c0c384 /Lib/test | |
parent | 13c25c08ca9e154e337cc7d7c258d9286304ed16 (diff) | |
download | cpython-12adef9b8b44f0535cfb5c30437541ef67327b17.zip cpython-12adef9b8b44f0535cfb5c30437541ef67327b17.tar.gz cpython-12adef9b8b44f0535cfb5c30437541ef67327b17.tar.bz2 |
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
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_resource.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index d1fd230..16e360f 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -49,17 +49,24 @@ class ResourceTest(unittest.TestCase): except ValueError: limit_set = False f = open(test_support.TESTFN, "wb") - f.write("X" * 1024) try: - f.write("Y") - f.flush() - except IOError: - if not limit_set: - raise - f.close() - os.unlink(test_support.TESTFN) + f.write("X" * 1024) + try: + f.write("Y") + f.flush() + except IOError: + if not limit_set: + 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: - resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) + if limit_set: + resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) def test_fsize_toobig(self): # Be sure that setrlimit is checking for really large values |