summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-12-10 17:38:52 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-12-10 17:38:52 (GMT)
commitd3a345a21f4e07469622d148308637f0d5e69cf5 (patch)
treed5f024cf16c893c19f07d90f3df6dacb3b2cd555
parent10a6ddb062251177ee5458f5c07b7bbec5534bc1 (diff)
parent964561bb7cbfd7ef48b8874b32e26ece9a68f6cd (diff)
downloadcpython-d3a345a21f4e07469622d148308637f0d5e69cf5.zip
cpython-d3a345a21f4e07469622d148308637f0d5e69cf5.tar.gz
cpython-d3a345a21f4e07469622d148308637f0d5e69cf5.tar.bz2
merge 3.2
-rw-r--r--Lib/test/test_subprocess.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 432d324..d263b5f 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -18,6 +18,12 @@ try:
except ImportError:
gc = None
+
+try:
+ import resource
+except ImportError:
+ resource = None
+
mswindows = (sys.platform == "win32")
#
@@ -824,12 +830,12 @@ class _SuppressCoreFiles(object):
def __enter__(self):
"""Try to save previous ulimit, then set it to (0, 0)."""
- try:
- import resource
- self.old_limit = resource.getrlimit(resource.RLIMIT_CORE)
- resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
- except (ImportError, ValueError, resource.error):
- pass
+ if resource is not None:
+ try:
+ self.old_limit = resource.getrlimit(resource.RLIMIT_CORE)
+ resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
+ except (ValueError, resource.error):
+ pass
if sys.platform == 'darwin':
# Check if the 'Crash Reporter' on OSX was configured
@@ -850,11 +856,11 @@ class _SuppressCoreFiles(object):
"""Return core file behavior to default."""
if self.old_limit is None:
return
- try:
- import resource
- resource.setrlimit(resource.RLIMIT_CORE, self.old_limit)
- except (ImportError, ValueError, resource.error):
- pass
+ if resource is not None:
+ try:
+ resource.setrlimit(resource.RLIMIT_CORE, self.old_limit)
+ except (ValueError, resource.error):
+ pass
@unittest.skipIf(mswindows, "POSIX specific tests")