From 265c5be4d59b865dd74c92a7f60a93cf8e8899a9 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 30 May 2025 13:48:01 +0900 Subject: [PATCH] Replace pkg_resources pkg_resources is deprecated and will be removed[1]. [1] https://setuptools.pypa.io/en/latest/pkg_resources.html Also get rid of the redundant os.path.abspath . Change-Id: Ic6b0c7908a73c5c2ebf1973466ac5855d1e17520 --- mistralclient/tests/unit/v2/test_environments.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/mistralclient/tests/unit/v2/test_environments.py b/mistralclient/tests/unit/v2/test_environments.py index ef42f866..30266fbc 100644 --- a/mistralclient/tests/unit/v2/test_environments.py +++ b/mistralclient/tests/unit/v2/test_environments.py @@ -14,11 +14,10 @@ import collections import copy -import os.path +import importlib.resources from oslo_serialization import jsonutils -import pkg_resources as pkg from urllib import parse from urllib import request @@ -61,11 +60,9 @@ class TestEnvironmentsV2(base.BaseClientV2Test): def test_create_with_json_file_uri(self): # The contents of env_v2.json must be equivalent to ENVIRONMENT - path = pkg.resource_filename( - 'mistralclient', + path = str(importlib.resources.files('mistralclient').joinpath( 'tests/unit/resources/env_v2.json' - ) - path = os.path.abspath(path) + )) # Convert the file path to file URI uri = parse.urljoin('file:', request.pathname2url(path)) @@ -115,10 +112,9 @@ class TestEnvironmentsV2(base.BaseClientV2Test): def test_update_with_yaml_file(self): # The contents of env_v2.json must be equivalent to ENVIRONMENT - path = pkg.resource_filename( - 'mistralclient', + path = str(importlib.resources.files('mistralclient').joinpath( 'tests/unit/resources/env_v2.json' - ) + )) data = collections.OrderedDict( utils.load_content( utils.get_contents_if_file(path)