diff --git a/httprunner/loader/check.py b/httprunner/loader/check.py index 888d38d3..2f7720f4 100644 --- a/httprunner/loader/check.py +++ b/httprunner/loader/check.py @@ -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) diff --git a/httprunner/loader/load.py b/httprunner/loader/load.py index bf75d20e..27fe0455 100644 --- a/httprunner/loader/load.py +++ b/httprunner/loader/load.py @@ -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 diff --git a/tests/test_loader/test_check.py b/tests/test_loader/test_check.py index 6160ad88..82325a96 100644 --- a/tests/test_loader/test_check.py +++ b/tests/test_loader/test_check.py @@ -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))