summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-06-13 00:12:30 (GMT)
committerBrett Cannon <brett@python.org>2013-06-13 00:12:30 (GMT)
commitc9a1bfed5d820b681debca52554fea76ba0a9ae0 (patch)
treeba3c9fd41acbffaa32bf6e09a323471778064be7 /Lib
parent603dcf27140ca109d11496eb4a57fe6440ddc915 (diff)
downloadcpython-c9a1bfed5d820b681debca52554fea76ba0a9ae0.zip
cpython-c9a1bfed5d820b681debca52554fea76ba0a9ae0.tar.gz
cpython-c9a1bfed5d820b681debca52554fea76ba0a9ae0.tar.bz2
Move test___all__ over to unittest.main() and use ModuleNotFoundError
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/regrtest.py16
-rw-r--r--Lib/test/support.py14
-rw-r--r--Lib/test/test___all__.py7
-rw-r--r--Lib/xmlrpc/server.py2
-rw-r--r--Lib/zipfile.py6
5 files changed, 21 insertions, 24 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 4c55db5..7602b2b 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -146,11 +146,11 @@ from inspect import isabstract
try:
import threading
-except ImportError:
+except ModuleNotFoundError:
threading = None
try:
import multiprocessing.process
-except ImportError:
+except ModuleNotFoundError:
multiprocessing = None
@@ -180,7 +180,7 @@ for module in sys.modules.values():
if sys.platform == 'darwin':
try:
import resource
- except ImportError:
+ except ModuleNotFoundError:
pass
else:
soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
@@ -571,7 +571,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if findleaks:
try:
import gc
- except ImportError:
+ except ModuleNotFoundError:
print('No GC available, disabling findleaks.')
findleaks = False
else:
@@ -692,7 +692,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if use_mp:
try:
from threading import Thread
- except ImportError:
+ except ModuleNotFoundError:
print("Multiprocess option requires thread support")
sys.exit(2)
from queue import Queue
@@ -1396,7 +1396,7 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
pic = sys.path_importer_cache.copy()
try:
import zipimport
- except ImportError:
+ except ModuleNotFoundError:
zdc = None # Run unmodified on platforms without zipimport support
else:
zdc = zipimport._zip_directory_cache.copy()
@@ -1473,7 +1473,7 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
sys.path_importer_cache.update(pic)
try:
import zipimport
- except ImportError:
+ except ModuleNotFoundError:
pass # Run unmodified on platforms without zipimport support
else:
zipimport._zip_directory_cache.clear()
@@ -1510,7 +1510,7 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
doctest.master = None
try:
import ctypes
- except ImportError:
+ except ModuleNotFoundError:
# Don't worry about resetting the cache if ctypes is not supported
pass
else:
diff --git a/Lib/test/support.py b/Lib/test/support.py
index 97de608..9baedb4 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -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():
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 093ea2f..d0d7fa3 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -75,7 +75,7 @@ class AllTest(unittest.TestCase):
try:
import rlcompleter
import locale
- except ImportError:
+ except ModuleNotFoundError:
pass
else:
locale.setlocale(locale.LC_CTYPE, 'C')
@@ -113,8 +113,5 @@ class AllTest(unittest.TestCase):
print('Following modules failed to be imported:', failed_imports)
-def test_main():
- support.run_unittest(AllTest)
-
if __name__ == "__main__":
- test_main()
+ unittest.main()
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
index 54e1726..80233e4 100644
--- a/Lib/xmlrpc/server.py
+++ b/Lib/xmlrpc/server.py
@@ -116,7 +116,7 @@ import inspect
import traceback
try:
import fcntl
-except ImportError:
+except ModuleNotFoundError:
fcntl = None
def resolve_dotted_attribute(obj, attr, allow_dotted_names=True):
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index b90af55..adaffe1 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -18,18 +18,18 @@ import binascii
try:
import zlib # We may need its compression method
crc32 = zlib.crc32
-except ImportError:
+except ModuleNotFoundError:
zlib = None
crc32 = binascii.crc32
try:
import bz2 # We may need its compression method
-except ImportError:
+except ModuleNotFoundError:
bz2 = None
try:
import lzma # We may need its compression method
-except ImportError:
+except ModuleNotFoundError:
lzma = None
__all__ = ["BadZipFile", "BadZipfile", "error",