mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 00:17:37 +08:00
refactor is_function
This commit is contained in:
@@ -239,7 +239,7 @@ def load_module_functions(module):
|
|||||||
module_functions = {}
|
module_functions = {}
|
||||||
|
|
||||||
for name, item in vars(module).items():
|
for name, item in vars(module).items():
|
||||||
if validator.is_function((name, item)):
|
if validator.is_function(item):
|
||||||
module_functions[name] = item
|
module_functions[name] = item
|
||||||
|
|
||||||
return module_functions
|
return module_functions
|
||||||
|
|||||||
@@ -105,10 +105,9 @@ def is_testcase_path(path):
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
def is_function(tup):
|
def is_function(item):
|
||||||
""" Takes (name, object) tuple, returns True if it is a function.
|
""" Takes item object, returns True if it is a function.
|
||||||
"""
|
"""
|
||||||
name, item = tup
|
|
||||||
return isinstance(item, types.FunctionType)
|
return isinstance(item, types.FunctionType)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,5 @@ class TestValidator(unittest.TestCase):
|
|||||||
|
|
||||||
def test_is_function(self):
|
def test_is_function(self):
|
||||||
func = lambda x: x + 1
|
func = lambda x: x + 1
|
||||||
self.assertTrue(validator.is_function(("func", func)))
|
self.assertTrue(validator.is_function(func))
|
||||||
|
self.assertTrue(validator.is_function(validator.is_testcase))
|
||||||
self.assertTrue(validator.is_function(("func", validator.is_testcase)))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user