summaryrefslogtreecommitdiff
path: root/Lib/test/test_winconsoleio.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-06 14:50:17 -0800
committerSteve Dower <steve.dower@microsoft.com>2017-02-06 14:50:17 -0800
commit2dfa6cb9ff3af066d65a4edff7a16bf8c9932f11 (patch)
treeef6ecaddd8a80f1262c3e42bad4d788f09a890ef /Lib/test/test_winconsoleio.py
parentf007b49eb95b3b713f101008fdd5a1eb39d43443 (diff)
downloadcpython-git-2dfa6cb9ff3af066d65a4edff7a16bf8c9932f11.tar.gz
Issue #28164: Improves test on Windows 7
Diffstat (limited to 'Lib/test/test_winconsoleio.py')
-rw-r--r--Lib/test/test_winconsoleio.py38
1 files changed, 22 insertions, 16 deletions
diff --git a/Lib/test/test_winconsoleio.py b/Lib/test/test_winconsoleio.py
index 0d88ae3e7d..656483cf16 100644
--- a/Lib/test/test_winconsoleio.py
+++ b/Lib/test/test_winconsoleio.py
@@ -6,6 +6,7 @@ import os
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 @@ class WindowsConsoleIOTests(unittest.TestCase):
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')