From 2f83777d9a7b38000a52f25aac98cd3ccf6f698b Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 14 Feb 2018 22:05:11 +0800 Subject: [PATCH] rename function --- httprunner/testcase.py | 12 ++++++------ tests/test_context.py | 2 +- tests/test_runner.py | 4 ++-- tests/test_testcase.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/httprunner/testcase.py b/httprunner/testcase.py index 9a912061..c079d3c9 100644 --- a/httprunner/testcase.py +++ b/httprunner/testcase.py @@ -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: diff --git a/tests/test_context.py b/tests/test_context.py index 56ae0e4c..a7e5a7a5 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -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) diff --git a/tests/test_runner.py b/tests/test_runner.py index f8ac6492..5752be73 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -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 } diff --git a/tests/test_testcase.py b/tests/test_testcase.py index c47c144d..3fcad5d6 100644 --- a/tests/test_testcase.py +++ b/tests/test_testcase.py @@ -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)