mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
update load_debugtalk_module
This commit is contained in:
@@ -6,7 +6,7 @@ import json
|
||||
import os
|
||||
|
||||
import yaml
|
||||
from httprunner import exceptions, logger, parser, utils, validator
|
||||
from httprunner import exceptions, logger, parser, validator
|
||||
from httprunner.compat import OrderedDict
|
||||
|
||||
###############################################################################
|
||||
@@ -224,17 +224,24 @@ def load_debugtalk_module(start_path=None):
|
||||
|
||||
"""
|
||||
start_path = start_path or os.getcwd()
|
||||
debugtalk_module = {
|
||||
"variables": {},
|
||||
"functions": {}
|
||||
}
|
||||
|
||||
try:
|
||||
module_name = locate_debugtalk_py(start_path)
|
||||
except exceptions.FileNotFound:
|
||||
return {}
|
||||
return debugtalk_module
|
||||
|
||||
imported_module = importlib.import_module(module_name)
|
||||
debugtalk_module = {
|
||||
"variables": utils.filter_module(imported_module, "variable"),
|
||||
"functions": utils.filter_module(imported_module, "function")
|
||||
}
|
||||
for name, item in vars(imported_module).items():
|
||||
if validator.is_function((name, item)):
|
||||
debugtalk_module["functions"][name] = item
|
||||
elif validator.is_variable((name, item)):
|
||||
debugtalk_module["variables"][name] = item
|
||||
else:
|
||||
pass
|
||||
|
||||
return debugtalk_module
|
||||
|
||||
|
||||
@@ -174,7 +174,8 @@ class TestModuleLoader(unittest.TestCase):
|
||||
|
||||
def test_load_debugtalk_module(self):
|
||||
imported_module_items = loader.load_debugtalk_module()
|
||||
self.assertEqual(imported_module_items, {})
|
||||
self.assertEqual(imported_module_items["functions"], {})
|
||||
self.assertEqual(imported_module_items["variables"], {})
|
||||
|
||||
imported_module_items = loader.load_debugtalk_module("tests")
|
||||
self.assertEqual(
|
||||
|
||||
Reference in New Issue
Block a user