mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #28164: Improves test on Windows 7
This commit is contained in:
parent
f007b49eb9
commit
2dfa6cb9ff
1 changed files with 22 additions and 16 deletions
|
@ -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,24 +98,29 @@ class WindowsConsoleIOTests(unittest.TestCase):
|
||||||
self.assertIsInstance(f, ConIO)
|
self.assertIsInstance(f, ConIO)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
try:
|
@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)
|
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)
|
self.assertIsInstance(f, ConIO)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
try:
|
|
||||||
f = open('//?/conout$', 'wb', buffering=0)
|
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)
|
self.assertIsInstance(f, ConIO)
|
||||||
f.close()
|
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):
|
def assertStdinRoundTrip(self, text):
|
||||||
stdin = open('CONIN$', 'r')
|
stdin = open('CONIN$', 'r')
|
||||||
old_stdin = sys.stdin
|
old_stdin = sys.stdin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue