refactor testcase config data structure

This commit is contained in:
httprunner
2018-11-15 21:49:05 +08:00
parent efc2520e81
commit 4142867fbd
5 changed files with 29 additions and 47 deletions

View File

@@ -165,12 +165,11 @@ class TestHttpRunner(ApiServerUnittest):
self.assertLess(end_time - start_time, 60)
def test_run_httprunner_with_teardown_hooks_alter_response(self):
config = {"name": "test teardown hooks"}
config.update(loader.load_project_tests("tests"))
testcases = [
{
"config": {
"name": "test teardown hooks",
"refs": loader.load_project_tests("tests")
},
"config": config,
"teststeps": [
{
"name": "test teardown hooks",

View File

@@ -240,7 +240,7 @@ class TestModuleLoader(unittest.TestCase):
self.assertEqual(testcases[0]["config"]["name"], '123$var_a')
self.assertIn(
"sum_two",
testcases[0]["config"]["refs"]["functions"]
testcases[0]["config"]["functions"]
)
@@ -394,14 +394,14 @@ class TestSuiteLoader(unittest.TestCase):
testcases_list = loader.load_tests(path)
self.assertEqual(len(testcases_list), 1)
self.assertEqual(len(testcases_list[0]["teststeps"]), 3)
self.assertIn("get_sign", testcases_list[0]["config"]["refs"]["functions"])
self.assertIn("get_sign", testcases_list[0]["config"]["functions"])
# relative file path
path = 'tests/data/demo_testcase_hardcode.yml'
testcases_list = loader.load_tests(path)
self.assertEqual(len(testcases_list), 1)
self.assertEqual(len(testcases_list[0]["teststeps"]), 3)
self.assertIn("get_sign", testcases_list[0]["config"]["refs"]["functions"])
self.assertIn("get_sign", testcases_list[0]["config"]["functions"])
# list/set container with file(s)
path = [