[Python-checkins] cpython (3.6): Updates test_winconsoleio to better show the source of its issues.

steve.dower python-checkins at python.org
Sat Feb 4 19:47:02 EST 2017


https://hg.python.org/cpython/rev/d5292aad642b
changeset:   106435:d5292aad642b
branch:      3.6
parent:      106433:0965e2967056
user:        Steve Dower <steve.dower at microsoft.com>
date:        Sat Feb 04 16:46:34 2017 -0800
summary:
  Updates test_winconsoleio to better show the source of its issues.

files:
  Lib/test/test_winconsoleio.py |  42 ++++++++++++++--------
  1 files changed, 27 insertions(+), 15 deletions(-)


diff --git a/Lib/test/test_winconsoleio.py b/Lib/test/test_winconsoleio.py
--- a/Lib/test/test_winconsoleio.py
+++ b/Lib/test/test_winconsoleio.py
@@ -1,11 +1,11 @@
 '''Tests for WindowsConsoleIO
 '''
 
+import io
 import os
-import io
 import sys
+import tempfile
 import unittest
-import tempfile
 
 if sys.platform != 'win32':
     raise unittest.SkipTest("test only relevant on win32")
@@ -26,8 +26,10 @@
 
         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 @@
     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 @@
         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

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list