]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 68782 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Mon, 19 Jan 2009 21:07:05 +0000 (21:07 +0000)
committerBenjamin Peterson <benjamin@python.org>
Mon, 19 Jan 2009 21:07:05 +0000 (21:07 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r68782 | benjamin.peterson | 2009-01-19 15:00:09 -0600 (Mon, 19 Jan 2009) | 9 lines

  Merged revisions 68779 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r68779 | benjamin.peterson | 2009-01-19 11:37:42 -0600 (Mon, 19 Jan 2009) | 1 line

    make bad file descriptor tests more robust
  ........
................

Lib/test/support.py
Lib/test/test_fileio.py

index 5f8b1ba1cdd57a369d73c90ac3d795c8f31a8b19..68791d514f96b1895d3675a288ecb3284bbff442 100644 (file)
@@ -344,6 +344,18 @@ def sortdict(dict):
     withcommas = ", ".join(reprpairs)
     return "{%s}" % withcommas
 
+def make_bad_fd():
+    """
+    Create an invalid file descriptor by opening and closing a file and return
+    its fd.
+    """
+    file = open(TESTFN, "wb")
+    try:
+        return file.fileno()
+    finally:
+        file.close()
+        unlink(TESTFN)
+
 def check_syntax_error(testcase, statement):
     try:
         compile(statement, '<test string>', 'exec')
index 69aa3fd23c0f359b43bc014f13059f2a775077e0..497914f583ebee967a3e4eedf1f50c7d3d85073d 100644 (file)
@@ -6,7 +6,8 @@ import unittest
 from array import array
 from weakref import proxy
 
-from test.support import TESTFN, findfile, check_warnings, run_unittest
+from test.support import (TESTFN, findfile, check_warnings, run_unittest,
+                          make_bad_fd)
 from collections import UserList
 
 import _fileio
@@ -177,7 +178,7 @@ class OtherFileTests(unittest.TestCase):
 
     def testInvalidFd(self):
         self.assertRaises(ValueError, _fileio._FileIO, -10)
-        self.assertRaises(OSError, _fileio._FileIO, 10)
+        self.assertRaises(OSError, _fileio._FileIO, make_bad_fd())
 
     def testBadModeArgument(self):
         # verify that we get a sensible error message for bad mode argument