From 2f93b2b73ad4e2973fd81d59c9d54c4315a4509f Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 15 May 2020 16:41:54 +0800 Subject: [PATCH] change: simplify testcase import --- .../postman_echo/request_methods/hardcode_test.py | 7 ++----- .../request_methods/request_with_functions_test.py | 7 ++----- .../request_with_testcase_reference_test.py | 7 ++----- .../request_methods/request_with_variables_test.py | 7 ++----- .../request_methods/validate_with_functions_test.py | 7 ++----- .../request_methods/validate_with_variables_test.py | 7 ++----- httprunner/__init__.py | 13 ++++++++++++- httprunner/ext/make/__init__.py | 7 ++----- 8 files changed, 26 insertions(+), 36 deletions(-) diff --git a/examples/postman_echo/request_methods/hardcode_test.py b/examples/postman_echo/request_methods/hardcode_test.py index c18e97cc..e66af98f 100644 --- a/examples/postman_echo/request_methods/hardcode_test.py +++ b/examples/postman_echo/request_methods/hardcode_test.py @@ -1,11 +1,8 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! -import unittest - -from httprunner.runner import HttpRunner -from httprunner.schema import TConfig, TStep +from httprunner import HttpRunner, TConfig, TStep, TestCase -class TestCaseHardcode(unittest.TestCase): +class TestCaseHardcode(TestCase): config = TConfig( **{ "name": "request methods testcase in hardcode", diff --git a/examples/postman_echo/request_methods/request_with_functions_test.py b/examples/postman_echo/request_methods/request_with_functions_test.py index aaa31321..68da74d9 100644 --- a/examples/postman_echo/request_methods/request_with_functions_test.py +++ b/examples/postman_echo/request_methods/request_with_functions_test.py @@ -1,11 +1,8 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! -import unittest - -from httprunner.runner import HttpRunner -from httprunner.schema import TConfig, TStep +from httprunner import HttpRunner, TConfig, TStep, TestCase -class TestCaseRequestWithFunctions(unittest.TestCase): +class TestCaseRequestWithFunctions(TestCase): config = TConfig( **{ "name": "request methods testcase with functions", diff --git a/examples/postman_echo/request_methods/request_with_testcase_reference_test.py b/examples/postman_echo/request_methods/request_with_testcase_reference_test.py index 63153c75..bf81cd95 100644 --- a/examples/postman_echo/request_methods/request_with_testcase_reference_test.py +++ b/examples/postman_echo/request_methods/request_with_testcase_reference_test.py @@ -1,11 +1,8 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! -import unittest - -from httprunner.runner import HttpRunner -from httprunner.schema import TConfig, TStep +from httprunner import HttpRunner, TConfig, TStep, TestCase -class TestCaseRequestWithTestcaseReference(unittest.TestCase): +class TestCaseRequestWithTestcaseReference(TestCase): config = TConfig( **{ "name": "request methods testcase: reference testcase", diff --git a/examples/postman_echo/request_methods/request_with_variables_test.py b/examples/postman_echo/request_methods/request_with_variables_test.py index 4f6e8f04..4a8a1ef6 100644 --- a/examples/postman_echo/request_methods/request_with_variables_test.py +++ b/examples/postman_echo/request_methods/request_with_variables_test.py @@ -1,11 +1,8 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! -import unittest - -from httprunner.runner import HttpRunner -from httprunner.schema import TConfig, TStep +from httprunner import HttpRunner, TConfig, TStep, TestCase -class TestCaseRequestWithVariables(unittest.TestCase): +class TestCaseRequestWithVariables(TestCase): config = TConfig( **{ "name": "request methods testcase with variables", diff --git a/examples/postman_echo/request_methods/validate_with_functions_test.py b/examples/postman_echo/request_methods/validate_with_functions_test.py index e397ba8c..4f66ca47 100644 --- a/examples/postman_echo/request_methods/validate_with_functions_test.py +++ b/examples/postman_echo/request_methods/validate_with_functions_test.py @@ -1,11 +1,8 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! -import unittest - -from httprunner.runner import HttpRunner -from httprunner.schema import TConfig, TStep +from httprunner import HttpRunner, TConfig, TStep, TestCase -class TestCaseValidateWithFunctions(unittest.TestCase): +class TestCaseValidateWithFunctions(TestCase): config = TConfig( **{ "name": "request methods testcase: validate with functions", diff --git a/examples/postman_echo/request_methods/validate_with_variables_test.py b/examples/postman_echo/request_methods/validate_with_variables_test.py index 10eaf7bc..72cd5140 100644 --- a/examples/postman_echo/request_methods/validate_with_variables_test.py +++ b/examples/postman_echo/request_methods/validate_with_variables_test.py @@ -1,11 +1,8 @@ # NOTICE: Generated By HttpRunner. DO'NOT EDIT! -import unittest - -from httprunner.runner import HttpRunner -from httprunner.schema import TConfig, TStep +from httprunner import HttpRunner, TConfig, TStep, TestCase -class TestCaseValidateWithVariables(unittest.TestCase): +class TestCaseValidateWithVariables(TestCase): config = TConfig( **{ "name": "request methods testcase: validate with variables", diff --git a/httprunner/__init__.py b/httprunner/__init__.py index ed28b566..abec38e2 100644 --- a/httprunner/__init__.py +++ b/httprunner/__init__.py @@ -1,4 +1,15 @@ __version__ = "3.0.2" __description__ = "One-stop solution for HTTP(S) testing." -__all__ = ["__version__", "__description__"] +from unittest import TestCase +from httprunner.runner import HttpRunner +from httprunner.schema import TConfig, TStep + +__all__ = [ + "__version__", + "__description__", + "HttpRunner", + "TConfig", + "TStep", + "TestCase", +] diff --git a/httprunner/ext/make/__init__.py b/httprunner/ext/make/__init__.py index e2ac5bf8..91a10356 100644 --- a/httprunner/ext/make/__init__.py +++ b/httprunner/ext/make/__init__.py @@ -10,13 +10,10 @@ from httprunner.exceptions import TestCaseFormatError from httprunner.loader import load_testcase_file, load_folder_files __TMPL__ = """# NOTICE: Generated By HttpRunner. DO'NOT EDIT! -import unittest - -from httprunner.runner import HttpRunner -from httprunner.schema import TConfig, TStep +from httprunner import HttpRunner, TConfig, TStep, TestCase -class {{ class_name }}(unittest.TestCase): +class {{ class_name }}(TestCase): config = TConfig(**{{ config }}) teststeps = [