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