Merge "python3.12: "fix" unittests"

This commit is contained in:
Zuul
2024-01-25 01:42:52 +00:00
committed by Gerrit Code Review
3 changed files with 35 additions and 12 deletions

View File

@@ -11,14 +11,22 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import imp import importlib
import mock import mock
import os import os
import sys
from oslotest import base from oslotest import base
module_path = (os.path.dirname(os.path.realpath(__file__)) +
'/../static/usr/local/sbin/growvols') importlib.machinery.SOURCE_SUFFIXES.append('')
growvols = imp.load_source('growvols', module_path) 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 # output of lsblk -Po kname,pkname,name,label,type,fstype,mountpoint
LSBLK = """KNAME="sda" PKNAME="" NAME="sda" LABEL="" TYPE="disk" FSTYPE="" MOUNTPOINT="" LSBLK = """KNAME="sda" PKNAME="" NAME="sda" LABEL="" TYPE="disk" FSTYPE="" MOUNTPOINT=""

View File

@@ -13,16 +13,23 @@
# under the License. # under the License.
import collections import collections
import functools import functools
import imp import importlib
import mock import mock
import os import os
import sys
from oslotest import base from oslotest import base
from testtools.matchers import Mismatch from testtools.matchers import Mismatch
installs_squash_src = (os.path.dirname(os.path.realpath(__file__)) + importlib.machinery.SOURCE_SUFFIXES.append('')
'/../bin/package-installs-squash') file_path = (os.path.dirname(os.path.realpath(__file__)) +
installs_squash = imp.load_source('installs_squash', installs_squash_src) '/../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): class IsMatchingInstallList(object):

View File

@@ -11,13 +11,21 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import imp import importlib
import os import os
import sys
from oslotest import base from oslotest import base
module_path = (os.path.dirname(os.path.realpath(__file__)) +
'/../extra-data.d/10-merge-svc-map-files') importlib.machinery.SOURCE_SUFFIXES.append('')
service_map = imp.load_source('service_map', module_path) 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): class TestDataMerge(base.BaseTestCase):