summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorJason Tishler <jason@tishler.net>2002-12-12 18:13:36 +0000
committerJason Tishler <jason@tishler.net>2002-12-12 18:13:36 +0000
commite4a070a3206809d069360c1a5d20541bf24d824b (patch)
treed73ba4a2452bd0e79702030f40950e65f8b23e5e /Lib/test
parent20b91358e5fd8042fbcaa4293fa37b7063fa77cf (diff)
downloadcpython-git-e4a070a3206809d069360c1a5d20541bf24d824b.tar.gz
Patch #551960: Add check for setrlimit() support
test_resource calls resource.setrlimit() to change the file size limits. This fails on Cygwin, which supports setrlimit() and getrlimit(), just not changing that particular setting. (The same would apply to any other platform that has those functions but not that particular feature.) Since getrlimit() works and setrlimit() can be used for other reasons, a check for ValueError was added to that part of the test.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_resource.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 12b8134a6a..29ce35bb0b 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -22,15 +22,23 @@ else:
# pythonrun.c has been fixed to ignore that exception. If so, the
# write() should return EFBIG when the limit is exceeded.
+# At least one platform has an unlimited RLIMIT_FSIZE and attempts to
+# change it raise ValueError instead.
+
try:
- resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max))
+ try:
+ resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max))
+ limit_set = 1
+ except ValueError:
+ limit_set = 0
f = open(TESTFN, "wb")
f.write("X" * 1024)
try:
f.write("Y")
f.flush()
except IOError:
- pass
+ if not limit_set:
+ raise
f.close()
os.unlink(TESTFN)
finally:
@@ -40,9 +48,9 @@ finally:
too_big = 10L**50
try:
resource.setrlimit(resource.RLIMIT_FSIZE, (too_big, max))
-except OverflowError:
+except (OverflowError, ValueError):
pass
try:
resource.setrlimit(resource.RLIMIT_FSIZE, (max, too_big))
-except OverflowError:
+except (OverflowError, ValueError):
pass