[Python-checkins] r56523 - python/trunk/Lib/test/test_resource.py

nick.coghlan python-checkins at python.org
Tue Jul 24 16:39:23 CEST 2007


Author: nick.coghlan
Date: Tue Jul 24 16:39:23 2007
New Revision: 56523
Modified:
 python/trunk/Lib/test/test_resource.py
Log:
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
Modified: python/trunk/Lib/test/test_resource.py
==============================================================================
--- python/trunk/Lib/test/test_resource.py	(original)
+++ python/trunk/Lib/test/test_resource.py	Tue Jul 24 16:39:23 2007
@@ -49,17 +49,24 @@
 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


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /