From cb57e4bec2941d773bdc9ac2afec62930ff79bc7 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 4 May 2018 19:43:23 +0800 Subject: [PATCH] bugfix #210: SuiteNotFound --- httprunner/__about__.py | 2 +- httprunner/runner.py | 2 -- httprunner/task.py | 1 + tests/suite/setup.yml | 3 +++ tests/test_httprunner.py | 7 +++++++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/httprunner/__about__.py b/httprunner/__about__.py index 65e5e5ee..803689bf 100644 --- a/httprunner/__about__.py +++ b/httprunner/__about__.py @@ -1,7 +1,7 @@ __title__ = 'HttpRunner' __description__ = 'One-stop solution for HTTP(S) testing.' __url__ = 'https://github.com/HttpRunner/HttpRunner' -__version__ = '1.4.0' +__version__ = '1.4.1' __author__ = 'debugtalk' __author_email__ = 'mail@debugtalk.com' __license__ = 'MIT' diff --git a/httprunner/runner.py b/httprunner/runner.py index 1c264c2b..7cd51e3a 100644 --- a/httprunner/runner.py +++ b/httprunner/runner.py @@ -6,7 +6,6 @@ from httprunner import exception, logger, response, utils from httprunner.client import HttpSession from httprunner.context import Context from httprunner.events import EventHook -from httprunner.testcase import TestcaseLoader class Runner(object): @@ -14,7 +13,6 @@ class Runner(object): def __init__(self, config_dict=None, http_client_session=None): self.http_client_session = http_client_session self.context = Context() - TestcaseLoader.load_test_dependencies() config_dict = config_dict or {} self.init_config(config_dict, "testset") diff --git a/httprunner/task.py b/httprunner/task.py index 6f1067fc..6cb728b5 100644 --- a/httprunner/task.py +++ b/httprunner/task.py @@ -196,6 +196,7 @@ def init_task_suite(path_or_testsets, mapping=None, http_client_session=None): """ initialize task suite """ if not testcase.is_testsets(path_or_testsets): + TestcaseLoader.load_test_dependencies() testsets = TestcaseLoader.load_testsets_by_path(path_or_testsets) else: testsets = path_or_testsets diff --git a/tests/suite/setup.yml b/tests/suite/setup.yml index beb89182..782aaaef 100644 --- a/tests/suite/setup.yml +++ b/tests/suite/setup.yml @@ -20,6 +20,9 @@ - app_version: '2.8.6' extract: - token: content.token + validate: + - eq: ["status_code", 200] + - len_eq: ["content.token", 16] - test: name: reset all users diff --git a/tests/test_httprunner.py b/tests/test_httprunner.py index 05b52fbc..a3d584c4 100644 --- a/tests/test_httprunner.py +++ b/tests/test_httprunner.py @@ -145,3 +145,10 @@ class TestHttpRunner(ApiServerUnittest): self.assertTrue(os.path.isfile(report)) report_save_dir = os.path.join(os.getcwd(), 'reports', output_folder_name) shutil.rmtree(report_save_dir) + + def test_testcase_layer(self): + testcase_path = "tests/testcases/smoketest.yml" + runner = HttpRunner(failfast=True).run(testcase_path) + summary = runner.summary + self.assertTrue(summary["success"]) + self.assertEqual(summary["stat"]["testsRun"], 8)