mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-111881: Use lazy import in test.support (#111885)
* Import lazily getpass in test.support * Only import ctypes on Windows in test.support.os_helper.
This commit is contained in:
parent
cc18b886a5
commit
0372e3b02a
2 changed files with 12 additions and 7 deletions
|
@ -10,6 +10,8 @@ import time
|
|||
import unittest
|
||||
import warnings
|
||||
|
||||
from test import support
|
||||
|
||||
|
||||
# Filename used for testing
|
||||
TESTFN_ASCII = '@test'
|
||||
|
@ -720,13 +722,16 @@ class EnvironmentVarGuard(collections.abc.MutableMapping):
|
|||
|
||||
|
||||
try:
|
||||
import ctypes
|
||||
kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
|
||||
if support.MS_WINDOWS:
|
||||
import ctypes
|
||||
kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
|
||||
|
||||
ERROR_FILE_NOT_FOUND = 2
|
||||
DDD_REMOVE_DEFINITION = 2
|
||||
DDD_EXACT_MATCH_ON_REMOVE = 4
|
||||
DDD_NO_BROADCAST_SYSTEM = 8
|
||||
ERROR_FILE_NOT_FOUND = 2
|
||||
DDD_REMOVE_DEFINITION = 2
|
||||
DDD_EXACT_MATCH_ON_REMOVE = 4
|
||||
DDD_NO_BROADCAST_SYSTEM = 8
|
||||
else:
|
||||
raise AttributeError
|
||||
except (ImportError, AttributeError):
|
||||
def subst_drive(path):
|
||||
raise unittest.SkipTest('ctypes or kernel32 is not available')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue