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