Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: switch from imp to importlib #3296

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions test/test_container_content_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
from . import fixture
import tempfile
import shutil
import sys
import os.path

from os.path import exists, join

import imp
import importlib
from subscription_manager.model import Content
from subscription_manager.plugin.container import (
ContainerContentUpdateActionCommand,
Expand Down Expand Up @@ -111,11 +112,12 @@ def test_multi_directory(self):

def test_post_install_main(self):
plugin_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src", "content_plugins"))
fp, pathname, description = imp.find_module("container_content", [plugin_path])
try:
container_content = imp.load_module("container_content", fp, pathname, description)
finally:
fp.close()
spec = importlib.util.spec_from_file_location(
"container_content", os.path.join(plugin_path, "container_content.py")
)
container_content = importlib.util.module_from_spec(spec)
sys.modules["container_content"] = container_content
spec.loader.exec_module(container_content)
plugin_manager = PluginManager(search_path=plugin_path, plugin_conf_path=plugin_path)
plugin_class = plugin_manager.get_plugins()["container_content.ContainerContentPlugin"]
with mock.patch.object(plugin_class, "HOSTNAME_CERT_DIR", self.host_cert_dir):
Expand Down