Update imp module to importlib
The imp module is deprecated[1] since version 3.4, use importlib to instead 1: https://docs.python.org/3/library/imp.html Change-Id: I79dfd923531dd3e00d23e1682865f56f0cf437d2
This commit is contained in:
parent
5dcd1dd915
commit
33970fcc6b
@ -11,7 +11,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import imp
|
import importlib.util
|
||||||
import json
|
import json
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
@ -19,13 +19,23 @@ from unittest import mock
|
|||||||
|
|
||||||
from oslotest import base
|
from oslotest import base
|
||||||
|
|
||||||
|
|
||||||
|
def load_module(name, path):
|
||||||
|
module_spec = importlib.util.spec_from_file_location(
|
||||||
|
name, path
|
||||||
|
)
|
||||||
|
module = importlib.util.module_from_spec(module_spec)
|
||||||
|
module_spec.loader.exec_module(module)
|
||||||
|
return module
|
||||||
|
|
||||||
|
|
||||||
# nasty: to import set_config (not a part of the kolla package)
|
# nasty: to import set_config (not a part of the kolla package)
|
||||||
this_dir = os.path.dirname(sys.modules[__name__].__file__)
|
this_dir = os.path.dirname(sys.modules[__name__].__file__)
|
||||||
set_configs_file = os.path.abspath(
|
set_configs_file = os.path.abspath(
|
||||||
os.path.join(this_dir, '..',
|
os.path.join(this_dir, '..',
|
||||||
'docker', 'base', 'set_configs.py'))
|
'docker', 'base', 'set_configs.py'))
|
||||||
|
|
||||||
set_configs = imp.load_source('set_configs', set_configs_file)
|
set_configs = load_module('set_configs', set_configs_file)
|
||||||
|
|
||||||
|
|
||||||
class LoadFromFile(base.BaseTestCase):
|
class LoadFromFile(base.BaseTestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user