tests: Replace imp with importlib.machinery
It's needed for Python3.12 support, because imp has been dropped [1]. Also shlex dropped s=None support [2]. [1]: https://docs.python.org/3/whatsnew/3.12.html [2]: https://github.com/python/cpython/issues/94352 Change-Id: I23f37897ea08ac708f6df485f699122df647e552
This commit is contained in:
parent
2a150d1be9
commit
3c3c517958
@ -78,6 +78,7 @@ class PodmanWorker(ContainerWorker):
|
||||
)
|
||||
|
||||
command = self.params.pop('command', '')
|
||||
if command:
|
||||
self.params['command'] = shlex.split(command)
|
||||
|
||||
# we have to transform volumes into mounts because podman-py
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
import copy
|
||||
import imp
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import os
|
||||
import sys
|
||||
from unittest import mock
|
||||
@ -32,8 +32,8 @@ kolla_container_file = os.path.join(ansible_dir,
|
||||
'library', 'kolla_container.py')
|
||||
docker_worker_file = os.path.join(ansible_dir,
|
||||
'module_utils', 'kolla_docker_worker.py')
|
||||
kc = imp.load_source('kolla_container', kolla_container_file)
|
||||
dwm = imp.load_source('kolla_docker_worker', docker_worker_file)
|
||||
kc = SourceFileLoader('kolla_container', kolla_container_file).load_module()
|
||||
dwm = SourceFileLoader('kolla_docker_worker', docker_worker_file).load_module()
|
||||
|
||||
|
||||
FAKE_DATA = {
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
import copy
|
||||
import imp
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
@ -31,8 +31,8 @@ kolla_container_file = os.path.join(ansible_dir,
|
||||
'library', 'kolla_container.py')
|
||||
podman_worker_file = os.path.join(ansible_dir,
|
||||
'module_utils', 'kolla_podman_worker.py')
|
||||
kc = imp.load_source('kolla_container', kolla_container_file)
|
||||
pwm = imp.load_source('kolla_podman_worker', podman_worker_file)
|
||||
kc = SourceFileLoader('kolla_container', kolla_container_file).load_module()
|
||||
pwm = SourceFileLoader('kolla_podman_worker', podman_worker_file).load_module()
|
||||
|
||||
FAKE_DATA = {
|
||||
'params': {
|
||||
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import imp
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import os
|
||||
import sys
|
||||
from unittest import mock
|
||||
@ -26,7 +26,8 @@ this_dir = os.path.dirname(sys.modules[__name__].__file__)
|
||||
ansible_dir = os.path.join(this_dir, '..', '..', 'ansible')
|
||||
systemd_worker_file = os.path.join(ansible_dir,
|
||||
'module_utils', 'kolla_systemd_worker.py')
|
||||
swm = imp.load_source('kolla_systemd_worker', systemd_worker_file)
|
||||
swm = SourceFileLoader('kolla_systemd_worker',
|
||||
systemd_worker_file).load_module()
|
||||
|
||||
|
||||
class TestSystemd(base.BaseTestCase):
|
||||
|
@ -12,7 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import imp
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -22,7 +22,7 @@ this_dir = os.path.dirname(sys.modules[__name__].__file__)
|
||||
file_under_test = os.path.join(this_dir, '..', 'ansible',
|
||||
'roles', 'keystone', 'files',
|
||||
'fernet_rotate_cron_generator.py')
|
||||
generator = imp.load_source('generator', file_under_test)
|
||||
generator = SourceFileLoader('generator', file_under_test).load_module()
|
||||
|
||||
|
||||
class FernetRotateCronGeneratorTest(base.BaseTestCase):
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
# FIXME(yoctozepto): tests do not imitate how ansible would handle module args
|
||||
|
||||
import imp
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import os
|
||||
import sys
|
||||
from unittest import mock
|
||||
@ -28,8 +28,8 @@ kolla_container_file = os.path.join(ansible_dir,
|
||||
'library', 'kolla_container.py')
|
||||
docker_worker_file = os.path.join(ansible_dir,
|
||||
'module_utils', 'kolla_docker_worker.py')
|
||||
kc = imp.load_source('kolla_container', kolla_container_file)
|
||||
dwm = imp.load_source('kolla_docker_worker', docker_worker_file)
|
||||
kc = SourceFileLoader('kolla_container', kolla_container_file).load_module()
|
||||
dwm = SourceFileLoader('kolla_docker_worker', docker_worker_file).load_module()
|
||||
|
||||
|
||||
class ModuleArgsTest(base.BaseTestCase):
|
||||
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import imp
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import os
|
||||
|
||||
from io import StringIO
|
||||
@ -25,7 +25,8 @@ MERGE_CONFIG_FILE = os.path.join(PROJECT_DIR,
|
||||
'ansible/action_plugins/merge_configs.py')
|
||||
|
||||
|
||||
merge_configs = imp.load_source('merge_configs', MERGE_CONFIG_FILE)
|
||||
merge_configs = SourceFileLoader('merge_configs',
|
||||
MERGE_CONFIG_FILE).load_module()
|
||||
|
||||
TESTA = '''[DEFAULT]
|
||||
key1 = b
|
||||
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import imp
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import os
|
||||
|
||||
from ansible.errors import AnsibleModuleError
|
||||
@ -22,7 +22,7 @@ from oslotest import base
|
||||
PROJECT_DIR = os.path.abspath(os.path.join(os. path.dirname(__file__), '../'))
|
||||
MERGE_YAML_FILE = os.path.join(PROJECT_DIR,
|
||||
'ansible/action_plugins/merge_yaml.py')
|
||||
merge_yaml = imp.load_source('merge_yaml', MERGE_YAML_FILE)
|
||||
merge_yaml = SourceFileLoader('merge_yaml', MERGE_YAML_FILE).load_module()
|
||||
|
||||
|
||||
class MergeYamlConfigTest(base.BaseTestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user