Skips console open_fd tests when we don't have real consoles.

This commit is contained in:
Steve Dower 2016-09-08 14:34:24 -07:00
parent 10427f4485
commit f09e2fa2e9
1 changed files with 21 additions and 18 deletions

View File

@ -25,26 +25,29 @@ class WindowsConsoleIOTests(unittest.TestCase):
self.assertFalse(issubclass(ConIO, io.TextIOBase))
def test_open_fd(self):
f = ConIO(0)
self.assertTrue(f.readable())
self.assertFalse(f.writable())
self.assertEqual(0, f.fileno())
f.close() # multiple close should not crash
f.close()
if sys.stdin.fileno() == 0:
f = ConIO(0)
self.assertTrue(f.readable())
self.assertFalse(f.writable())
self.assertEqual(0, f.fileno())
f.close() # multiple close should not crash
f.close()
f = ConIO(1, 'w')
self.assertFalse(f.readable())
self.assertTrue(f.writable())
self.assertEqual(1, f.fileno())
f.close()
f.close()
if sys.stdout.fileno() == 1:
f = ConIO(1, 'w')
self.assertFalse(f.readable())
self.assertTrue(f.writable())
self.assertEqual(1, f.fileno())
f.close()
f.close()
f = ConIO(2, 'w')
self.assertFalse(f.readable())
self.assertTrue(f.writable())
self.assertEqual(2, f.fileno())
f.close()
f.close()
if sys.stderr.fileno() == 2:
f = ConIO(2, 'w')
self.assertFalse(f.readable())
self.assertTrue(f.writable())
self.assertEqual(2, f.fileno())
f.close()
f.close()
def test_open_name(self):
f = ConIO("CON")