mirror of
https://github.com/python/cpython.git
synced 2025-07-30 22:54:16 +00:00
Move test___all__ over to unittest.main() and use ModuleNotFoundError
This commit is contained in:
parent
603dcf2714
commit
c9a1bfed5d
5 changed files with 21 additions and 24 deletions
|
@ -29,27 +29,27 @@ import _testcapi
|
|||
|
||||
try:
|
||||
import _thread, threading
|
||||
except ImportError:
|
||||
except ModuleNotFoundError:
|
||||
_thread = None
|
||||
threading = None
|
||||
try:
|
||||
import multiprocessing.process
|
||||
except ImportError:
|
||||
except ModuleNotFoundError:
|
||||
multiprocessing = None
|
||||
|
||||
try:
|
||||
import zlib
|
||||
except ImportError:
|
||||
except ModuleNotFoundError:
|
||||
zlib = None
|
||||
|
||||
try:
|
||||
import bz2
|
||||
except ImportError:
|
||||
except ModuleNotFoundError:
|
||||
bz2 = None
|
||||
|
||||
try:
|
||||
import lzma
|
||||
except ImportError:
|
||||
except ModuleNotFoundError:
|
||||
lzma = None
|
||||
|
||||
__all__ = [
|
||||
|
@ -116,7 +116,7 @@ def import_module(name, deprecated=False, *, required_on=()):
|
|||
with _ignore_deprecated_imports(deprecated):
|
||||
try:
|
||||
return importlib.import_module(name)
|
||||
except ImportError as msg:
|
||||
except ModuleNotFoundError as msg:
|
||||
if sys.platform.startswith(tuple(required_on)):
|
||||
raise
|
||||
raise unittest.SkipTest(str(msg))
|
||||
|
@ -188,7 +188,7 @@ def import_fresh_module(name, fresh=(), blocked=(), deprecated=False):
|
|||
if not _save_and_block_module(blocked_name, orig_modules):
|
||||
names_to_remove.append(blocked_name)
|
||||
fresh_module = importlib.import_module(name)
|
||||
except ImportError:
|
||||
except ModuleNotFoundError:
|
||||
fresh_module = None
|
||||
finally:
|
||||
for orig_name, module in orig_modules.items():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue