[Python-checkins] r68784 - in python/branches/release30-maint: Lib/test/support.py Lib/test/test_fileio.py
benjamin.peterson
python-checkins at python.org
Mon Jan 19 22:07:05 CET 2009
Author: benjamin.peterson
Date: Mon Jan 19 22:07:05 2009
New Revision: 68784
Log:
Merged revisions 68782 via svnmerge from
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
........
................
Modified:
python/branches/release30-maint/ (props changed)
python/branches/release30-maint/Lib/test/support.py
python/branches/release30-maint/Lib/test/test_fileio.py
Modified: python/branches/release30-maint/Lib/test/support.py
==============================================================================
--- python/branches/release30-maint/Lib/test/support.py (original)
+++ python/branches/release30-maint/Lib/test/support.py Mon Jan 19 22:07:05 2009
@@ -344,6 +344,18 @@
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')
Modified: python/branches/release30-maint/Lib/test/test_fileio.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_fileio.py (original)
+++ python/branches/release30-maint/Lib/test/test_fileio.py Mon Jan 19 22:07:05 2009
@@ -6,7 +6,8 @@
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 @@
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
More information about the Python-checkins
mailing list