summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-04 16:46:34 -0800
committerSteve Dower <steve.dower@microsoft.com>2017-02-04 16:46:34 -0800
commit391ed6c73cb1964b57d0b538370a76d03d30511b (patch)
tree08f8b0ccbcfe1bc155ee1ba7a00a6dcf03051626
parent1a5780aabb550cae175ad8711e2f33ba644d0ddb (diff)
downloadcpython-391ed6c73cb1964b57d0b538370a76d03d30511b.tar.gz
Updates test_winconsoleio to better show the source of its issues.
-rw-r--r--Lib/test/test_winconsoleio.py42
1 files changed, 27 insertions, 15 deletions
diff --git a/Lib/test/test_winconsoleio.py b/Lib/test/test_winconsoleio.py
index 06467e905a..0d88ae3e7d 100644
--- a/Lib/test/test_winconsoleio.py
+++ b/Lib/test/test_winconsoleio.py
@@ -1,11 +1,11 @@
'''Tests for WindowsConsoleIO
'''
-import os
import io
+import os
import sys
-import unittest
import tempfile
+import unittest
if sys.platform != 'win32':
raise unittest.SkipTest("test only relevant on win32")
@@ -26,8 +26,10 @@ class WindowsConsoleIOTests(unittest.TestCase):
fd, _ = tempfile.mkstemp()
try:
+ # Windows 10: "Cannot open non-console file"
+ # Earlier: "Cannot open console output buffer for reading"
self.assertRaisesRegex(ValueError,
- "Cannot open non-console file", ConIO, fd)
+ "Cannot open (console|non-console file)", ConIO, fd)
finally:
os.close(fd)
@@ -70,18 +72,6 @@ class WindowsConsoleIOTests(unittest.TestCase):
def test_open_name(self):
self.assertRaises(ValueError, ConIO, sys.executable)
- f = open('C:/con', 'rb', buffering=0)
- self.assertIsInstance(f, ConIO)
- f.close()
-
- f = open(r'\\.\conin$', 'rb', buffering=0)
- self.assertIsInstance(f, ConIO)
- f.close()
-
- f = open('//?/conout$', 'wb', buffering=0)
- self.assertIsInstance(f, ConIO)
- f.close()
-
f = ConIO("CON")
self.assertTrue(f.readable())
self.assertFalse(f.writable())
@@ -103,6 +93,28 @@ class WindowsConsoleIOTests(unittest.TestCase):
f.close()
f.close()
+ f = open('C:/con', 'rb', buffering=0)
+ self.assertIsInstance(f, ConIO)
+ f.close()
+
+ try:
+ f = open(r'\\.\conin$', 'rb', buffering=0)
+ except FileNotFoundError:
+ # If we cannot find the file, this part should be skipped
+ print('\\\\.\\conin$ was not found on this OS')
+ else:
+ self.assertIsInstance(f, ConIO)
+ f.close()
+
+ try:
+ f = open('//?/conout$', 'wb', buffering=0)
+ except FileNotFoundError:
+ # If we cannot find the file, this part should be skipped
+ print('//?/conout$ was not found on this OS')
+ else:
+ self.assertIsInstance(f, ConIO)
+ f.close()
+
def assertStdinRoundTrip(self, text):
stdin = open('CONIN$', 'r')
old_stdin = sys.stdin