Kaydet (Commit) b98cb43e authored tarafından Guilherme Polo's avatar Guilherme Polo

Moving to importlib

üst b64c989e
...@@ -9,6 +9,7 @@ Extensions also should live in packages following the same rule as above. ...@@ -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): ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment