fix: importlib.reload only works in python 3

This commit is contained in:
debugtalk
2022-04-30 15:17:22 +08:00
parent be8c053ed8
commit d028f95bb3

View File

@@ -3,16 +3,17 @@ import os
import sys
from httprunner import exceptions, logger, utils
from httprunner.compat import is_py3
from httprunner.loader.check import JsonSchemaChecker
from httprunner.loader.load import (
load_module_functions,
load_file,
load_dot_env_file,
load_file,
load_folder_files,
load_module_functions,
)
from httprunner.loader.locate import (
init_project_working_directory,
get_project_working_directory,
init_project_working_directory,
)
tests_def_mapping = {"api": {}, "testcases": {}}
@@ -31,7 +32,8 @@ def load_debugtalk_functions():
"""
# load debugtalk.py module
if sys.modules.get("debugtalk"):
if is_py3 and sys.modules.get("debugtalk"):
# importlib.reload only works in python 3
imported_module = importlib.reload(sys.modules["debugtalk"])
else:
imported_module = importlib.import_module("debugtalk")