diff --git a/diskimage_builder/elements/growvols/tests/test_growvols.py b/diskimage_builder/elements/growvols/tests/test_growvols.py index 5817b6def..461df58c1 100644 --- a/diskimage_builder/elements/growvols/tests/test_growvols.py +++ b/diskimage_builder/elements/growvols/tests/test_growvols.py @@ -11,14 +11,22 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import imp +import importlib import mock import os +import sys from oslotest import base -module_path = (os.path.dirname(os.path.realpath(__file__)) + - '/../static/usr/local/sbin/growvols') -growvols = imp.load_source('growvols', module_path) + +importlib.machinery.SOURCE_SUFFIXES.append('') +file_path = (os.path.dirname(os.path.realpath(__file__)) + + '/../static/usr/local/sbin/growvols') +spec = importlib.util.spec_from_file_location('growvols', file_path) +module = importlib.util.module_from_spec(spec) +spec.loader.exec_module(module) +sys.modules['growvols'] = module +growvols = module +importlib.machinery.SOURCE_SUFFIXES.pop() # output of lsblk -Po kname,pkname,name,label,type,fstype,mountpoint LSBLK = """KNAME="sda" PKNAME="" NAME="sda" LABEL="" TYPE="disk" FSTYPE="" MOUNTPOINT="" diff --git a/diskimage_builder/elements/package-installs/tests/test_package_squash.py b/diskimage_builder/elements/package-installs/tests/test_package_squash.py index 631c987f0..2ea0665ba 100644 --- a/diskimage_builder/elements/package-installs/tests/test_package_squash.py +++ b/diskimage_builder/elements/package-installs/tests/test_package_squash.py @@ -13,16 +13,23 @@ # under the License. import collections import functools -import imp +import importlib import mock import os +import sys from oslotest import base from testtools.matchers import Mismatch -installs_squash_src = (os.path.dirname(os.path.realpath(__file__)) + - '/../bin/package-installs-squash') -installs_squash = imp.load_source('installs_squash', installs_squash_src) +importlib.machinery.SOURCE_SUFFIXES.append('') +file_path = (os.path.dirname(os.path.realpath(__file__)) + + '/../bin/package-installs-squash') +spec = importlib.util.spec_from_file_location('installs_squash', file_path) +module = importlib.util.module_from_spec(spec) +spec.loader.exec_module(module) +sys.modules['installs_squash'] = module +installs_squash = module +importlib.machinery.SOURCE_SUFFIXES.pop() class IsMatchingInstallList(object): diff --git a/diskimage_builder/elements/svc-map/tests/test_data_merge.py b/diskimage_builder/elements/svc-map/tests/test_data_merge.py index 2e016a8c1..a53b9f298 100644 --- a/diskimage_builder/elements/svc-map/tests/test_data_merge.py +++ b/diskimage_builder/elements/svc-map/tests/test_data_merge.py @@ -11,13 +11,21 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import imp +import importlib import os +import sys from oslotest import base -module_path = (os.path.dirname(os.path.realpath(__file__)) + - '/../extra-data.d/10-merge-svc-map-files') -service_map = imp.load_source('service_map', module_path) + +importlib.machinery.SOURCE_SUFFIXES.append('') +file_path = (os.path.dirname(os.path.realpath(__file__)) + + '/../extra-data.d/10-merge-svc-map-files') +spec = importlib.util.spec_from_file_location('service_map', file_path) +module = importlib.util.module_from_spec(spec) +spec.loader.exec_module(module) +sys.modules['service_map'] = module +service_map = module +importlib.machinery.SOURCE_SUFFIXES.pop() class TestDataMerge(base.BaseTestCase):