refactor loading of SMTP action module in tests (deprecated load_module removed in v.3.15)

This commit is contained in:
Sergey G. Brester 2026-01-01 21:49:12 +01:00 committed by GitHub
parent 7528fce11b
commit 247667c9c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,6 +22,7 @@ import threading
import unittest
import re
import sys
import types
import importlib
from ..dummyjail import DummyJail
@ -296,10 +297,11 @@ try:
self.jail = DummyJail()
pythonModule = os.path.join(CONFIG_DIR, "action.d", "smtp.py")
pythonModuleName = os.path.basename(pythonModule.rstrip(".py"))
customActionModule = importlib.machinery.SourceFileLoader(
pythonModuleName, pythonModule).load_module()
ldr = importlib.machinery.SourceFileLoader(pythonModuleName, pythonModule)
mod = types.ModuleType(ldr.name)
ldr.exec_module(mod)
self.action = customActionModule.Action(
self.action = mod.Action(
self.jail, "test", host="localhost:%i" % self.port)
self.action.ssl = True