mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
@@ -42,7 +42,7 @@ class Context(object):
|
|||||||
self.import_module_items(["ate.built_in"], "testset")
|
self.import_module_items(["ate.built_in"], "testset")
|
||||||
|
|
||||||
def import_requires(self, modules):
|
def import_requires(self, modules):
|
||||||
""" import required modules dynamicly
|
""" import required modules dynamically
|
||||||
"""
|
"""
|
||||||
for module_name in modules:
|
for module_name in modules:
|
||||||
globals()[module_name] = utils.get_imported_module(module_name)
|
globals()[module_name] = utils.get_imported_module(module_name)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class ApiTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def create_suite(testset):
|
def create_suite(testset):
|
||||||
""" create test suite with a testset, it may include one or several testcases.
|
""" create test suite with a testset, it may include one or several testcases.
|
||||||
each suite should initialize a seperate Runner() with testset config.
|
each suite should initialize a separate Runner() with testset config.
|
||||||
"""
|
"""
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ def load_testcases(testcase_file_path):
|
|||||||
# '' or other suffix
|
# '' or other suffix
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def load_foler_files(folder_path, match_filter_list=["*"]):
|
def load_folder_files(folder_path, match_filter_list=["*"]):
|
||||||
""" load folder path, return all files in list format.
|
""" load folder path, return all files in list format.
|
||||||
"""
|
"""
|
||||||
file_list = []
|
file_list = []
|
||||||
@@ -99,7 +99,7 @@ def load_testcases_by_path(path):
|
|||||||
path = os.path.join(os.getcwd(), path)
|
path = os.path.join(os.getcwd(), path)
|
||||||
|
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
files_list = load_foler_files(path, ["*.yml", "*.yaml", "*.json"])
|
files_list = load_folder_files(path, ["*.yml", "*.yaml", "*.json"])
|
||||||
return load_testcases_by_path(files_list)
|
return load_testcases_by_path(files_list)
|
||||||
|
|
||||||
elif os.path.isfile(path):
|
elif os.path.isfile(path):
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class TestcaseParserUnittest(unittest.TestCase):
|
|||||||
self.assertEqual(testcase.parse_string_value("$var"), "$var")
|
self.assertEqual(testcase.parse_string_value("$var"), "$var")
|
||||||
self.assertEqual(testcase.parse_string_value("${func}"), "${func}")
|
self.assertEqual(testcase.parse_string_value("${func}"), "${func}")
|
||||||
|
|
||||||
def test_parse_functon(self):
|
def test_parse_function(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
testcase.parse_function("${func()}"),
|
testcase.parse_function("${func()}"),
|
||||||
{'func_name': 'func', 'args': [], 'kwargs': {}}
|
{'func_name': 'func', 'args': [], 'kwargs': {}}
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ class TestUtils(ApiServerUnittest):
|
|||||||
self.assertIn('url', testcase['request'])
|
self.assertIn('url', testcase['request'])
|
||||||
self.assertIn('method', testcase['request'])
|
self.assertIn('method', testcase['request'])
|
||||||
|
|
||||||
def test_load_foler_files(self):
|
def test_load_folder_files(self):
|
||||||
folder = os.path.join(os.getcwd(), 'tests')
|
folder = os.path.join(os.getcwd(), 'tests')
|
||||||
file1 = os.path.join(os.getcwd(), 'tests', 'test_utils.py')
|
file1 = os.path.join(os.getcwd(), 'tests', 'test_utils.py')
|
||||||
file2 = os.path.join(os.getcwd(), 'tests', 'data', 'demo_binds.yml')
|
file2 = os.path.join(os.getcwd(), 'tests', 'data', 'demo_binds.yml')
|
||||||
|
|
||||||
files = utils.load_foler_files(folder, ["*.py"])
|
files = utils.load_folder_files(folder, ["*.py"])
|
||||||
self.assertIn(file1, files)
|
self.assertIn(file1, files)
|
||||||
self.assertNotIn(file2, files)
|
self.assertNotIn(file2, files)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user