mirror of
https://github.com/python/cpython.git
synced 2025-07-31 23:23:11 +00:00
Moving to importlib
This commit is contained in:
parent
b64c989efc
commit
b98cb43e4a
1 changed files with 3 additions and 4 deletions
|
@ -9,6 +9,7 @@ Extensions also should live in packages following the same rule as above.
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
import importlib
|
||||||
import test.test_support
|
import test.test_support
|
||||||
|
|
||||||
this_dir_path = os.path.abspath(os.path.dirname(__file__))
|
this_dir_path = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
@ -44,10 +45,8 @@ def get_tests_modules(basepath=this_dir_path, gui=True, packages=None):
|
||||||
|
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
try:
|
try:
|
||||||
yield __import__(
|
yield importlib.import_module(
|
||||||
"%s.%s" % (pkg_name, name[:-len(py_ext)]),
|
".%s" % name[:-len(py_ext)], pkg_name)
|
||||||
fromlist=['']
|
|
||||||
)
|
|
||||||
except test.test_support.ResourceDenied:
|
except test.test_support.ResourceDenied:
|
||||||
if gui:
|
if gui:
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue