diff Lib/test/test_os.py @ 44785:b520d33bee06 legacy-trunk

#1663329: add os.closerange() to close a range of fds, ignoring errors, and use this in subprocess to speed up subprocess creation in close_fds mode. Patch by Mike Klaas.
author Georg Brandl <georg@python.org>
date Sat, 19 Jan 2008 20:22:13 +0000
parents 68f8b2393243
children 61d22701a5e5
line wrap: on
line diff
--- a/Lib/test/test_os.py	Sat Jan 19 20:12:04 2008 +0000
+++ b/Lib/test/test_os.py	Sat Jan 19 20:22:13 2008 +0000
@@ -23,6 +23,12 @@
         os.close(f)
         self.assert_(os.access(test_support.TESTFN, os.W_OK))
 
+    def test_closerange(self):
+        f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
+        # close a fd that is open, and one that isn't
+        os.closerange(f, f+2)
+        self.assertRaises(OSError, os.write, f, "a")
+
 
 class TemporaryFileTests(unittest.TestCase):
     def setUp(self):