Kaydet (Commit) 4f69b7e3 authored tarafından Kristján Valur Jónsson's avatar Kristján Valur Jónsson

Make all the invalid fd tests for os subject to the function being available.

üst 71ba215d
...@@ -547,12 +547,15 @@ class TestInvalidFD(unittest.TestCase): ...@@ -547,12 +547,15 @@ class TestInvalidFD(unittest.TestCase):
locals()["test_"+f] = get_single(f) locals()["test_"+f] = get_single(f)
def test_isatty(self): def test_isatty(self):
if hasattr(os, "isatty"):
self.assertEqual(os.isatty(10), False) self.assertEqual(os.isatty(10), False)
def test_closerange(self): def test_closerange(self):
if hasattr(os, "closerange"):
self.assertEqual(os.closerange(10, 20), None) self.assertEqual(os.closerange(10, 20), None)
def test_dup2(self): def test_dup2(self):
if hasattr(os, "dup2"):
self.assertRaises(OSError, os.dup2, 10, 20) self.assertRaises(OSError, os.dup2, 10, 20)
def test_fchmod(self): def test_fchmod(self):
...@@ -573,9 +576,11 @@ class TestInvalidFD(unittest.TestCase): ...@@ -573,9 +576,11 @@ class TestInvalidFD(unittest.TestCase):
self.assertRaises(IOError, os.ftruncate, 10, 0) self.assertRaises(IOError, os.ftruncate, 10, 0)
def test_lseek(self): def test_lseek(self):
if hasattr(os, "lseek"):
self.assertRaises(OSError, os.lseek, 10, 0, 0) self.assertRaises(OSError, os.lseek, 10, 0, 0)
def test_read(self): def test_read(self):
if hasattr(os, "read"):
self.assertRaises(OSError, os.read, 10, 1) self.assertRaises(OSError, os.read, 10, 1)
def test_tcsetpgrpt(self): def test_tcsetpgrpt(self):
...@@ -583,6 +588,7 @@ class TestInvalidFD(unittest.TestCase): ...@@ -583,6 +588,7 @@ class TestInvalidFD(unittest.TestCase):
self.assertRaises(OSError, os.tcsetpgrp, 10, 0) self.assertRaises(OSError, os.tcsetpgrp, 10, 0)
def test_write(self): def test_write(self):
if hasattr(os, "write"):
self.assertRaises(OSError, os.write, 10, " ") self.assertRaises(OSError, os.write, 10, " ")
if sys.platform != 'win32': if sys.platform != 'win32':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment