Commit 6ef726af authored by Berker Peksag's avatar Berker Peksag Committed by GitHub

bpo-29734: Cleanup test_getfinalpathname_handles test (GH-12908)

parent d59b662e
...@@ -2337,19 +2337,10 @@ class Win32JunctionTests(unittest.TestCase): ...@@ -2337,19 +2337,10 @@ class Win32JunctionTests(unittest.TestCase):
@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
class Win32NtTests(unittest.TestCase): class Win32NtTests(unittest.TestCase):
def setUp(self):
from test import support
self.nt = support.import_module('nt')
pass
def tearDown(self):
pass
def test_getfinalpathname_handles(self): def test_getfinalpathname_handles(self):
try: nt = support.import_module('nt')
import ctypes, ctypes.wintypes ctypes = support.import_module('ctypes')
except ImportError: import ctypes.wintypes
raise unittest.SkipTest('ctypes module is required for this test')
kernel = ctypes.WinDLL('Kernel32.dll', use_last_error=True) kernel = ctypes.WinDLL('Kernel32.dll', use_last_error=True)
kernel.GetCurrentProcess.restype = ctypes.wintypes.HANDLE kernel.GetCurrentProcess.restype = ctypes.wintypes.HANDLE
...@@ -2368,21 +2359,23 @@ class Win32NtTests(unittest.TestCase): ...@@ -2368,21 +2359,23 @@ class Win32NtTests(unittest.TestCase):
before_count = handle_count.value before_count = handle_count.value
# The first two test the error path, __file__ tests the success path # The first two test the error path, __file__ tests the success path
filenames = [ r'\\?\C:', filenames = [
r'\\?\NUL', r'\\?\C:',
r'\\?\CONIN', r'\\?\NUL',
__file__ ] r'\\?\CONIN',
__file__,
]
for i in range(10): for _ in range(10):
for name in filenames: for name in filenames:
try: try:
tmp = self.nt._getfinalpathname(name) nt._getfinalpathname(name)
except: except Exception:
# Failure is expected # Failure is expected
pass pass
try: try:
tmp = os.stat(name) os.stat(name)
except: except Exception:
pass pass
ok = kernel.GetProcessHandleCount(hproc, ctypes.byref(handle_count)) ok = kernel.GetProcessHandleCount(hproc, ctypes.byref(handle_count))
......
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