summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2009-07-22 15:20:27 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2009-07-22 15:20:27 (GMT)
commit630cc4821c775f2b456b0744c39dc8531c75e54b (patch)
tree8cae078f9ce83a612f296f77c249b988b7889387 /Lib
parent953152f0640d7c99b9ffe03392a4c9ce590489cb (diff)
downloadcpython-630cc4821c775f2b456b0744c39dc8531c75e54b.zip
cpython-630cc4821c775f2b456b0744c39dc8531c75e54b.tar.gz
cpython-630cc4821c775f2b456b0744c39dc8531c75e54b.tar.bz2
Issue 6542: Make sure that TestInvalidFD.test_closerange does not
close any valid file descriptors.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_os.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 63f409e..62edd6c 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -617,7 +617,18 @@ class TestInvalidFD(unittest.TestCase):
def test_closerange(self):
if hasattr(os, "closerange"):
fd = support.make_bad_fd()
- self.assertEqual(os.closerange(fd, fd + 10), None)
+ # Make sure none of the descriptors we are about to close are
+ # currently valid (issue 6542).
+ for i in range(10):
+ try: os.fstat(fd+i)
+ except OSError:
+ pass
+ else:
+ break
+ if i < 2:
+ raise unittest.SkipTest(
+ "Unable to acquire a range of invalid file descriptors")
+ self.assertEqual(os.closerange(fd, fd + i-1), None)
def test_dup2(self):
if hasattr(os, "dup2"):