Fix tests on Python 3.12

We were seeing the following test failures on Python 3.12:

  openstackclient.tests.unit.common.test_module.TestModuleList.test_module_list_all
  openstackclient.tests.unit.common.test_module.TestModuleList.test_module_list_no_options

Both failures were caused by missing attributes of 'sys', e.g.

  AttributeError: module 'sys' has no attribute 'builtin_module_names'

Fix this by exposing the real 'sys' module as part of our mock of
'sys.modules'.

Change-Id: I17391a46f08896f49dccaf75ad685dab1375a03d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-05-10 11:16:56 +01:00
parent 5e5b89f906
commit 4c31284936

View File

@ -15,6 +15,7 @@
"""Test module module"""
import sys
from unittest import mock
from openstackclient.common import module as osc_module
@ -43,6 +44,7 @@ module_name_5 = '_private_module.lib'
module_version_5 = '0.0.1'
MODULES = {
'sys': sys,
module_name_1: fakes.FakeModule(module_name_1, module_version_1),
module_name_2: fakes.FakeModule(module_name_2, module_version_2),
module_name_3: fakes.FakeModule(module_name_3, module_version_3),