From 4f69b7e33be14ecec2ecb43a63d23662a9be81e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 15 Jan 2009 22:46:26 +0000 Subject: [PATCH] Make all the invalid fd tests for os subject to the function being available. --- Lib/test/test_os.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index aa7b59114d9..88e4f626185 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -547,13 +547,16 @@ class TestInvalidFD(unittest.TestCase): locals()["test_"+f] = get_single(f) def test_isatty(self): - self.assertEqual(os.isatty(10), False) + if hasattr(os, "isatty"): + self.assertEqual(os.isatty(10), False) def test_closerange(self): - self.assertEqual(os.closerange(10, 20), None) + if hasattr(os, "closerange"): + self.assertEqual(os.closerange(10, 20), None) def test_dup2(self): - self.assertRaises(OSError, os.dup2, 10, 20) + if hasattr(os, "dup2"): + self.assertRaises(OSError, os.dup2, 10, 20) def test_fchmod(self): if hasattr(os, "fchmod"): @@ -573,17 +576,20 @@ class TestInvalidFD(unittest.TestCase): self.assertRaises(IOError, os.ftruncate, 10, 0) def test_lseek(self): - self.assertRaises(OSError, os.lseek, 10, 0, 0) + if hasattr(os, "lseek"): + self.assertRaises(OSError, os.lseek, 10, 0, 0) def test_read(self): - self.assertRaises(OSError, os.read, 10, 1) + if hasattr(os, "read"): + self.assertRaises(OSError, os.read, 10, 1) def test_tcsetpgrpt(self): if hasattr(os, "tcsetpgrp"): self.assertRaises(OSError, os.tcsetpgrp, 10, 0) def test_write(self): - self.assertRaises(OSError, os.write, 10, " ") + if hasattr(os, "write"): + self.assertRaises(OSError, os.write, 10, " ") if sys.platform != 'win32': class Win32ErrorTests(unittest.TestCase):