replaced imp with importlib
This commit is contained in:
parent
bc0672bec7
commit
4bd032247d
23
run.py
23
run.py
@ -17,7 +17,7 @@ except ImportError:
|
||||
from distro import linux_distribution as dist
|
||||
import getpass
|
||||
import subprocess
|
||||
import imp
|
||||
import importlib
|
||||
import xml.dom.minidom
|
||||
try:
|
||||
import jinja2
|
||||
@ -35,6 +35,17 @@ FN_COVERAGE = 'coverage.xml'
|
||||
REPORT_FILES = [FN_DATA_COLLECTION, FN_COVERAGE, FN_PDF_REPORT]
|
||||
|
||||
|
||||
def load_source(modname, filename):
|
||||
loader = importlib.machinery.SourceFileLoader(modname, filename)
|
||||
spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
# The module is always executed and not cached in sys.modules.
|
||||
# Uncomment the following line to cache the module.
|
||||
# sys.modules[module.__name__] = module
|
||||
loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def testresults_filename(ut_folder, filename):
|
||||
return os.path.join(jsonlog.get_ut_testresult_folder(ut_folder), filename)
|
||||
|
||||
@ -184,7 +195,7 @@ def unittest_release_testcases(ut_folder):
|
||||
|
||||
|
||||
def unittest_prepare(ut_folder):
|
||||
config = imp.load_source('', jsonlog.get_ut_config(ut_folder))
|
||||
config = load_source('', jsonlog.get_ut_config(ut_folder))
|
||||
#
|
||||
output.print_header("Initiating unittest for first testrun...")
|
||||
if not os.path.exists(testresults_filename(ut_folder, '')):
|
||||
@ -239,8 +250,8 @@ def unittest_prepare(ut_folder):
|
||||
|
||||
|
||||
def unittest_testrun(ut_folder, options):
|
||||
tests = imp.load_source('', os.path.join(jsonlog.get_ut_testcase_folder(ut_folder), '__init__.py'))
|
||||
config = imp.load_source('', jsonlog.get_ut_config(ut_folder))
|
||||
tests = load_source('', os.path.join(jsonlog.get_ut_testcase_folder(ut_folder), '__init__.py'))
|
||||
config = load_source('', jsonlog.get_ut_config(ut_folder))
|
||||
#
|
||||
interpreter_version = 'python ' + '.'.join(['%d' % n for n in sys.version_info[:3]]) + ' (%s)' % sys.version_info[3]
|
||||
#
|
||||
@ -272,7 +283,7 @@ def unittest_testrun(ut_folder, options):
|
||||
|
||||
|
||||
def unittest_finalise(ut_folder):
|
||||
config = imp.load_source('', jsonlog.get_ut_config(ut_folder))
|
||||
config = load_source('', jsonlog.get_ut_config(ut_folder))
|
||||
#
|
||||
output.print_header("Adding Requirement information")
|
||||
#
|
||||
@ -328,7 +339,7 @@ def unittest_finalise(ut_folder):
|
||||
|
||||
|
||||
def unittest_publish(ut_folder):
|
||||
config = imp.load_source('', jsonlog.get_ut_config(ut_folder))
|
||||
config = load_source('', jsonlog.get_ut_config(ut_folder))
|
||||
output.print_header('Checking testrun state')
|
||||
output.print_action('Release State...')
|
||||
rs = jsonlog.get_ut_release_state(ut_folder)
|
||||
|
Loading…
x
Reference in New Issue
Block a user