mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
refactor: check if is function
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import json
|
||||
import os
|
||||
import types
|
||||
|
||||
import jsonschema
|
||||
|
||||
@@ -199,9 +198,3 @@ def is_testcase_path(path):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def is_function(item):
|
||||
""" Takes item object, returns True if it is a function.
|
||||
"""
|
||||
return isinstance(item, types.FunctionType)
|
||||
|
||||
@@ -2,12 +2,12 @@ import csv
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import types
|
||||
|
||||
import yaml
|
||||
|
||||
from httprunner import builtin
|
||||
from httprunner import exceptions, logger, utils
|
||||
from httprunner.loader.check import is_function
|
||||
from httprunner.loader.locate import get_project_working_directory
|
||||
|
||||
try:
|
||||
@@ -206,7 +206,7 @@ def load_module_functions(module):
|
||||
module_functions = {}
|
||||
|
||||
for name, item in vars(module).items():
|
||||
if is_function(item):
|
||||
if isinstance(item, types.FunctionType):
|
||||
module_functions[name] = item
|
||||
|
||||
return module_functions
|
||||
|
||||
@@ -5,11 +5,6 @@ from httprunner.loader import check
|
||||
|
||||
class TestLoaderCheck(unittest.TestCase):
|
||||
|
||||
def test_is_function(self):
|
||||
func = lambda x: x + 1
|
||||
self.assertTrue(check.is_function(func))
|
||||
self.assertTrue(check.is_function(check.is_testcase))
|
||||
|
||||
def test_is_testcases(self):
|
||||
data_structure = "path/to/file"
|
||||
self.assertFalse(check.is_testcases(data_structure))
|
||||
|
||||
Reference in New Issue
Block a user