mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
make custom module importable anywhere
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import copy
|
import copy
|
||||||
import importlib
|
import importlib
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import types
|
import types
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
@@ -67,6 +69,7 @@ class Context(object):
|
|||||||
def import_module_functions(self, modules, level="testcase"):
|
def import_module_functions(self, modules, level="testcase"):
|
||||||
""" import modules and bind all functions within the context
|
""" import modules and bind all functions within the context
|
||||||
"""
|
"""
|
||||||
|
sys.path.insert(0, os.getcwd())
|
||||||
for module_name in modules:
|
for module_name in modules:
|
||||||
imported = importlib.import_module(module_name)
|
imported = importlib.import_module(module_name)
|
||||||
imported_functions_dict = dict(filter(is_function, vars(imported).items()))
|
imported_functions_dict = dict(filter(is_function, vars(imported).items()))
|
||||||
|
|||||||
Reference in New Issue
Block a user