Commit 18d2c934 authored by Steve Dower's avatar Steve Dower

Issue #28164: Improves test on Windows 7

parents d947e4da 2dfa6cb9
...@@ -6,6 +6,7 @@ import os ...@@ -6,6 +6,7 @@ import os
import sys import sys
import tempfile import tempfile
import unittest import unittest
from test import support
if sys.platform != 'win32': if sys.platform != 'win32':
raise unittest.SkipTest("test only relevant on win32") raise unittest.SkipTest("test only relevant on win32")
...@@ -97,23 +98,28 @@ class WindowsConsoleIOTests(unittest.TestCase): ...@@ -97,23 +98,28 @@ class WindowsConsoleIOTests(unittest.TestCase):
self.assertIsInstance(f, ConIO) self.assertIsInstance(f, ConIO)
f.close() f.close()
try: @unittest.skipIf(sys.getwindowsversion()[:2] <= (6, 1),
f = open(r'\\.\conin$', 'rb', buffering=0) "test does not work on Windows 7 and earlier")
except FileNotFoundError: def test_conin_conout_names(self):
# If we cannot find the file, this part should be skipped f = open(r'\\.\conin$', 'rb', buffering=0)
print('\\\\.\\conin$ was not found on this OS') self.assertIsInstance(f, ConIO)
else: f.close()
self.assertIsInstance(f, ConIO)
f.close()
try: f = open('//?/conout$', 'wb', buffering=0)
f = open('//?/conout$', 'wb', buffering=0) self.assertIsInstance(f, ConIO)
except FileNotFoundError: f.close()
# If we cannot find the file, this part should be skipped
print('//?/conout$ was not found on this OS') def test_conout_path(self):
else: temp_path = tempfile.mkdtemp()
self.assertIsInstance(f, ConIO) self.addCleanup(support.rmtree, temp_path)
f.close()
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): def assertStdinRoundTrip(self, text):
stdin = open('CONIN$', 'r') stdin = open('CONIN$', 'r')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment