diff options
author | R. David Murray <rdmurray@bitdance.com> | 2009-07-22 17:22:58 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2009-07-22 17:22:58 (GMT) |
commit | 46ca2f25ebd7bfaa588c9e5fac8b8c7b8415b3a3 (patch) | |
tree | c00be72bc5436a64a568229e701ecbf5cf83565a /Lib | |
parent | d38d344370bbeb8c08d0d9aa2143e2852ee46de9 (diff) | |
download | cpython-46ca2f25ebd7bfaa588c9e5fac8b8c7b8415b3a3.zip cpython-46ca2f25ebd7bfaa588c9e5fac8b8c7b8415b3a3.tar.gz cpython-46ca2f25ebd7bfaa588c9e5fac8b8c7b8415b3a3.tar.bz2 |
Backport of fix for issue 6542: make sure
test_os.TestInvalidFD.test_closerange does not close any
valid file descriptors.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_os.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index fa82a75..207963e 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -563,7 +563,18 @@ class TestInvalidFD(unittest.TestCase): def test_closerange(self): if hasattr(os, "closerange"): fd = test_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"): |