From 4c312849364d1e5711fb97a1303b66078fed017d Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 10 May 2024 11:16:56 +0100 Subject: [PATCH] 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 --- openstackclient/tests/unit/common/test_module.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openstackclient/tests/unit/common/test_module.py b/openstackclient/tests/unit/common/test_module.py index 68255a04e1..476538a194 100644 --- a/openstackclient/tests/unit/common/test_module.py +++ b/openstackclient/tests/unit/common/test_module.py @@ -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),