[Python-checkins] cpython (3.6): Issue #28164: Improves test on Windows 7

steve.dower python-checkins at python.org
Mon Feb 6 17:53:31 EST 2017


https://hg.python.org/cpython/rev/4463e311f5bd
changeset:   106454:4463e311f5bd
branch:      3.6
parent:      106452:9c325166ba5f
user:        Steve Dower <steve.dower at microsoft.com>
date:        Mon Feb 06 14:50:17 2017 -0800
summary:
  Issue #28164: Improves test on Windows 7

files:
  Lib/test/test_winconsoleio.py |  38 +++++++++++++---------
  1 files changed, 22 insertions(+), 16 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
@@ -6,6 +6,7 @@
 import sys
 import tempfile
 import unittest
+from test import support
 
 if sys.platform != 'win32':
     raise unittest.SkipTest("test only relevant on win32")
@@ -97,23 +98,28 @@
         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()
+    @unittest.skipIf(sys.getwindowsversion()[:2] <= (6, 1),
+        "test does not work on Windows 7 and earlier")
+    def test_conin_conout_names(self):
+        f = open(r'\\.\conin$', 'rb', buffering=0)
+        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()
+        f = open('//?/conout$', 'wb', buffering=0)
+        self.assertIsInstance(f, ConIO)
+        f.close()
+
+    def test_conout_path(self):
+        temp_path = tempfile.mkdtemp()
+        self.addCleanup(support.rmtree, temp_path)
+
+        conout_path = os.path.join(temp_path, 'CONOUT$')
+
+        with open(conout_path, 'wb', buffering=0) as f:
+            if sys.getwindowsversion()[:2] > (6, 1):
+                self.assertIsInstance(f, ConIO)
+            else:
+                self.assertNotIsInstance(f, ConIO)
 
     def assertStdinRoundTrip(self, text):
         stdin = open('CONIN$', 'r')

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


More information about the Python-checkins mailing list