summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2019-04-22 15:46:28 (GMT)
committerGitHub <noreply@github.com>2019-04-22 15:46:28 (GMT)
commit6ef726af3ec106013c7c4261ddb306854f2b1778 (patch)
tree15ed046e426f6b9600e5c8bddaa558332a4fd21c /Lib
parentd59b662e490d3fae662c5f81fa5248f0445d2158 (diff)
downloadcpython-6ef726af3ec106013c7c4261ddb306854f2b1778.zip
cpython-6ef726af3ec106013c7c4261ddb306854f2b1778.tar.gz
cpython-6ef726af3ec106013c7c4261ddb306854f2b1778.tar.bz2
bpo-29734: Cleanup test_getfinalpathname_handles test (GH-12908)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_os.py35
1 files changed, 14 insertions, 21 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 4c620cc..bbadb81 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -2337,19 +2337,10 @@ class Win32JunctionTests(unittest.TestCase):
@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
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):
- try:
- import ctypes, ctypes.wintypes
- except ImportError:
- raise unittest.SkipTest('ctypes module is required for this test')
+ nt = support.import_module('nt')
+ ctypes = support.import_module('ctypes')
+ import ctypes.wintypes
kernel = ctypes.WinDLL('Kernel32.dll', use_last_error=True)
kernel.GetCurrentProcess.restype = ctypes.wintypes.HANDLE
@@ -2368,21 +2359,23 @@ class Win32NtTests(unittest.TestCase):
before_count = handle_count.value
# The first two test the error path, __file__ tests the success path
- filenames = [ r'\\?\C:',
- r'\\?\NUL',
- r'\\?\CONIN',
- __file__ ]
+ filenames = [
+ r'\\?\C:',
+ r'\\?\NUL',
+ r'\\?\CONIN',
+ __file__,
+ ]
- for i in range(10):
+ for _ in range(10):
for name in filenames:
try:
- tmp = self.nt._getfinalpathname(name)
- except:
+ nt._getfinalpathname(name)
+ except Exception:
# Failure is expected
pass
try:
- tmp = os.stat(name)
- except:
+ os.stat(name)
+ except Exception:
pass
ok = kernel.GetProcessHandleCount(hproc, ctypes.byref(handle_count))