Skip to content

Commit

Permalink
Make this working with python 3.12.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Jul 11, 2024
1 parent 53938b1 commit 4f15d79
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/test_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##import sys
##sys.path.insert(0, 'dist/b2bua')

from imp import find_module, load_module
from importlib.util import spec_from_file_location, module_from_spec
import os

from sippy.SdpOrigin import SdpOrigin
Expand Down Expand Up @@ -32,9 +32,17 @@ def load_cfg(side):
try:
scn = os.environ['MM_AUTH']
except KeyError as ex:
raise ImportError()
mf = find_module(side + '_cfg', ['scenarios/' + scn,])
m = load_module(side + '_cfg', *mf)
raise ImportError('MM_AUTH is not set') from ex
module_name = side + '_cfg'
module_path = 'scenarios/' + scn + '/' + module_name + '.py'
spec = spec_from_file_location(module_name, module_path)
emsg = f'Could not find module {module_name} in {module_path}'
if spec is None: raise ImportError(emsg)
m = module_from_spec(spec)
try:
spec.loader.exec_module(m)
except FileNotFoundError as ex:
raise ImportError(emsg) from ex
return m

class test_case_config(object):
Expand Down

0 comments on commit 4f15d79

Please sign in to comment.