mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
rename function
This commit is contained in:
@@ -42,15 +42,15 @@ def _load_json_file(json_file):
|
||||
check_format(json_file, json_content)
|
||||
return json_content
|
||||
|
||||
def _load_file(testcase_file_path):
|
||||
file_suffix = os.path.splitext(testcase_file_path)[1]
|
||||
def load_file(file_path):
|
||||
file_suffix = os.path.splitext(file_path)[1]
|
||||
if file_suffix == '.json':
|
||||
return _load_json_file(testcase_file_path)
|
||||
return _load_json_file(file_path)
|
||||
elif file_suffix in ['.yaml', '.yml']:
|
||||
return _load_yaml_file(testcase_file_path)
|
||||
return _load_yaml_file(file_path)
|
||||
else:
|
||||
# '' or other suffix
|
||||
err_msg = u"file is not in YAML/JSON format: {}".format(testcase_file_path)
|
||||
err_msg = u"file is not in YAML/JSON format: {}".format(file_path)
|
||||
logging.warning(err_msg)
|
||||
return []
|
||||
|
||||
@@ -400,7 +400,7 @@ def load_test_file(file_path):
|
||||
"api": {},
|
||||
"testcases": []
|
||||
}
|
||||
tests_list = _load_file(file_path)
|
||||
tests_list = load_file(file_path)
|
||||
|
||||
for item in tests_list:
|
||||
for key in item:
|
||||
|
||||
@@ -12,7 +12,7 @@ class VariableBindsUnittest(ApiServerUnittest):
|
||||
def setUp(self):
|
||||
self.context = Context()
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo_binds.yml')
|
||||
self.testcases = testcase._load_file(testcase_file_path)
|
||||
self.testcases = testcase.load_file(testcase_file_path)
|
||||
|
||||
def test_context_init_functions(self):
|
||||
self.assertIn("get_timestamp", self.context.testset_functions_config)
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestRunner(ApiServerUnittest):
|
||||
|
||||
def test_run_single_testcase(self):
|
||||
for testcase_file_path in self.testcase_file_path_list:
|
||||
testcases = testcase._load_file(testcase_file_path)
|
||||
testcases = testcase.load_file(testcase_file_path)
|
||||
|
||||
config_dict = {
|
||||
"path": testcase_file_path
|
||||
@@ -150,7 +150,7 @@ class TestRunner(ApiServerUnittest):
|
||||
def test_bugfix_type_match(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/test_bugfix.yml')
|
||||
testcases = testcase._load_file(testcase_file_path)
|
||||
testcases = testcase.load_file(testcase_file_path)
|
||||
config_dict = {
|
||||
"path": testcase_file_path
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ class TestcaseParserUnittest(unittest.TestCase):
|
||||
|
||||
def test_load_testcases_bad_filepath(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo')
|
||||
self.assertEqual(testcase._load_file(testcase_file_path), [])
|
||||
self.assertEqual(testcase.load_file(testcase_file_path), [])
|
||||
|
||||
def test_load_json_testcases(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_hardcode.json')
|
||||
testcases = testcase._load_file(testcase_file_path)
|
||||
testcases = testcase.load_file(testcase_file_path)
|
||||
self.assertEqual(len(testcases), 3)
|
||||
test = testcases[0]["test"]
|
||||
self.assertIn('name', test)
|
||||
@@ -26,7 +26,7 @@ class TestcaseParserUnittest(unittest.TestCase):
|
||||
def test_load_yaml_testcases(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_hardcode.yml')
|
||||
testcases = testcase._load_file(testcase_file_path)
|
||||
testcases = testcase.load_file(testcase_file_path)
|
||||
self.assertEqual(len(testcases), 3)
|
||||
test = testcases[0]["test"]
|
||||
self.assertIn('name', test)
|
||||
|
||||
Reference in New Issue
Block a user