diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-01-19 21:00:09 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-01-19 21:00:09 (GMT) |
commit | 7522c748b1548c14dcc88a4857ab963d7fe66e84 (patch) | |
tree | a781c14fe27532678bbbaeafc79e0d7fe2bb01ba /Lib/test/test_os.py | |
parent | 9053d7548592f4a583d99595d9bbf0050e920da4 (diff) | |
download | cpython-7522c748b1548c14dcc88a4857ab963d7fe66e84.zip cpython-7522c748b1548c14dcc88a4857ab963d7fe66e84.tar.gz cpython-7522c748b1548c14dcc88a4857ab963d7fe66e84.tar.bz2 |
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
........
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index a2e611f..baaf33a 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -594,55 +594,59 @@ class TestInvalidFD(unittest.TestCase): #We omit close because it doesn'r raise an exception on some platforms def get_single(f): def helper(self): - if getattr(os, f, None): - self.assertRaises(OSError, getattr(os, f), 10) + if hasattr(os, f): + self.check(getattr(os, f)) return helper for f in singles: locals()["test_"+f] = get_single(f) + def check(self, f, *args): + self.assertRaises(OSError, f, support.make_bad_fd(), *args) + def test_isatty(self): if hasattr(os, "isatty"): - self.assertEqual(os.isatty(10), False) + self.assertEqual(os.isatty(support.make_bad_fd()), False) def test_closerange(self): if hasattr(os, "closerange"): - self.assertEqual(os.closerange(10, 20), None) + fd = support.make_bad_fd() + self.assertEqual(os.closerange(fd, fd + 10), None) def test_dup2(self): if hasattr(os, "dup2"): - self.assertRaises(OSError, os.dup2, 10, 20) + self.check(os.dup2, 20) def test_fchmod(self): if hasattr(os, "fchmod"): - self.assertRaises(OSError, os.fchmod, 10, 0) + self.check(os.fchmod, 0) def test_fchown(self): if hasattr(os, "fchown"): - self.assertRaises(OSError, os.fchown, 10, -1, -1) + self.check(os.fchown, -1, -1) def test_fpathconf(self): if hasattr(os, "fpathconf"): - self.assertRaises(OSError, os.fpathconf, 10, "PC_NAME_MAX") + self.check(os.fpathconf, "PC_NAME_MAX") def test_ftruncate(self): if hasattr(os, "ftruncate"): - self.assertRaises(OSError, os.ftruncate, 10, 0) + self.check(os.ftruncate, 0) def test_lseek(self): if hasattr(os, "lseek"): - self.assertRaises(OSError, os.lseek, 10, 0, 0) + self.check(os.lseek, 0, 0) def test_read(self): if hasattr(os, "read"): - self.assertRaises(OSError, os.read, 10, 1) + self.check(os.read, 1) def test_tcsetpgrpt(self): if hasattr(os, "tcsetpgrp"): - self.assertRaises(OSError, os.tcsetpgrp, 10, 0) + self.check(os.tcsetpgrp, 0) def test_write(self): if hasattr(os, "write"): - self.assertRaises(OSError, os.write, 10, b" ") + self.check(os.write, b" ") if sys.platform != 'win32': class Win32ErrorTests(unittest.TestCase): |