mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
change: rename schema model name and class name
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from httprunner.runner import TestCaseRunner
|
from httprunner.runner import HttpRunner
|
||||||
from httprunner.schema import TestsConfig, TestStep
|
from httprunner.schema import TConfig, TStep
|
||||||
|
|
||||||
|
|
||||||
class TestCaseHardcode(unittest.TestCase):
|
class TestCaseHardcode(unittest.TestCase):
|
||||||
config = TestsConfig(
|
config = TConfig(
|
||||||
**{
|
**{
|
||||||
"name": "request methods testcase in hardcode",
|
"name": "request methods testcase in hardcode",
|
||||||
"base_url": "https://postman-echo.com",
|
"base_url": "https://postman-echo.com",
|
||||||
@@ -16,7 +16,7 @@ class TestCaseHardcode(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
teststeps = [
|
teststeps = [
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "get with params",
|
"name": "get with params",
|
||||||
"request": {
|
"request": {
|
||||||
@@ -28,7 +28,7 @@ class TestCaseHardcode(unittest.TestCase):
|
|||||||
"validate": [{"eq": ["status_code", 200]}],
|
"validate": [{"eq": ["status_code", 200]}],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "post raw text",
|
"name": "post raw text",
|
||||||
"request": {
|
"request": {
|
||||||
@@ -43,7 +43,7 @@ class TestCaseHardcode(unittest.TestCase):
|
|||||||
"validate": [{"eq": ["status_code", 200]}],
|
"validate": [{"eq": ["status_code", 200]}],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "post form data",
|
"name": "post form data",
|
||||||
"request": {
|
"request": {
|
||||||
@@ -58,7 +58,7 @@ class TestCaseHardcode(unittest.TestCase):
|
|||||||
"validate": [{"eq": ["status_code", 200]}],
|
"validate": [{"eq": ["status_code", 200]}],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "put request",
|
"name": "put request",
|
||||||
"request": {
|
"request": {
|
||||||
@@ -76,4 +76,4 @@ class TestCaseHardcode(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_start(self):
|
def test_start(self):
|
||||||
TestCaseRunner(self.config, self.teststeps).run()
|
HttpRunner(self.config, self.teststeps).run()
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from httprunner.runner import TestCaseRunner
|
from httprunner.runner import HttpRunner
|
||||||
from httprunner.schema import TestsConfig, TestStep
|
from httprunner.schema import TConfig, TStep
|
||||||
|
|
||||||
|
|
||||||
class TestCaseRequestWithFunctions(unittest.TestCase):
|
class TestCaseRequestWithFunctions(unittest.TestCase):
|
||||||
config = TestsConfig(
|
config = TConfig(
|
||||||
**{
|
**{
|
||||||
"name": "request methods testcase with functions",
|
"name": "request methods testcase with functions",
|
||||||
"variables": {"foo1": "session_bar1"},
|
"variables": {"foo1": "session_bar1"},
|
||||||
@@ -17,7 +17,7 @@ class TestCaseRequestWithFunctions(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
teststeps = [
|
teststeps = [
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "get with params",
|
"name": "get with params",
|
||||||
"variables": {
|
"variables": {
|
||||||
@@ -40,7 +40,7 @@ class TestCaseRequestWithFunctions(unittest.TestCase):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "post raw text",
|
"name": "post raw text",
|
||||||
"variables": {"foo1": "hello world", "foo3": "$session_foo2"},
|
"variables": {"foo1": "hello world", "foo3": "$session_foo2"},
|
||||||
@@ -64,7 +64,7 @@ class TestCaseRequestWithFunctions(unittest.TestCase):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "post form data",
|
"name": "post form data",
|
||||||
"variables": {"foo1": "bar1", "foo2": "bar2"},
|
"variables": {"foo1": "bar1", "foo2": "bar2"},
|
||||||
@@ -87,4 +87,4 @@ class TestCaseRequestWithFunctions(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_start(self):
|
def test_start(self):
|
||||||
TestCaseRunner(self.config, self.teststeps).run()
|
HttpRunner(self.config, self.teststeps).run()
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from httprunner.runner import TestCaseRunner
|
from httprunner.runner import HttpRunner
|
||||||
from httprunner.schema import TestsConfig, TestStep
|
from httprunner.schema import TConfig, TStep
|
||||||
|
|
||||||
|
|
||||||
class TestCaseRequestWithTestcaseReference(unittest.TestCase):
|
class TestCaseRequestWithTestcaseReference(unittest.TestCase):
|
||||||
config = TestsConfig(
|
config = TConfig(
|
||||||
**{
|
**{
|
||||||
"name": "request methods testcase: reference testcase",
|
"name": "request methods testcase: reference testcase",
|
||||||
"variables": {"foo1": "session_bar1"},
|
"variables": {"foo1": "session_bar1"},
|
||||||
@@ -17,7 +17,7 @@ class TestCaseRequestWithTestcaseReference(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
teststeps = [
|
teststeps = [
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "request with variables",
|
"name": "request with variables",
|
||||||
"variables": {"foo1": "override_bar1"},
|
"variables": {"foo1": "override_bar1"},
|
||||||
@@ -27,4 +27,4 @@ class TestCaseRequestWithTestcaseReference(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_start(self):
|
def test_start(self):
|
||||||
TestCaseRunner(self.config, self.teststeps).run()
|
HttpRunner(self.config, self.teststeps).run()
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from httprunner.runner import TestCaseRunner
|
from httprunner.runner import HttpRunner
|
||||||
from httprunner.schema import TestsConfig, TestStep
|
from httprunner.schema import TConfig, TStep
|
||||||
|
|
||||||
|
|
||||||
class TestCaseRequestWithVariables(unittest.TestCase):
|
class TestCaseRequestWithVariables(unittest.TestCase):
|
||||||
config = TestsConfig(
|
config = TConfig(
|
||||||
**{
|
**{
|
||||||
"name": "request methods testcase with variables",
|
"name": "request methods testcase with variables",
|
||||||
"variables": {"foo1": "session_bar1"},
|
"variables": {"foo1": "session_bar1"},
|
||||||
@@ -17,7 +17,7 @@ class TestCaseRequestWithVariables(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
teststeps = [
|
teststeps = [
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "get with params",
|
"name": "get with params",
|
||||||
"variables": {"foo1": "bar1", "foo2": "session_bar2"},
|
"variables": {"foo1": "bar1", "foo2": "session_bar2"},
|
||||||
@@ -35,7 +35,7 @@ class TestCaseRequestWithVariables(unittest.TestCase):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "post raw text",
|
"name": "post raw text",
|
||||||
"variables": {"foo1": "hello world", "foo3": "$session_foo2"},
|
"variables": {"foo1": "hello world", "foo3": "$session_foo2"},
|
||||||
@@ -59,7 +59,7 @@ class TestCaseRequestWithVariables(unittest.TestCase):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "post form data",
|
"name": "post form data",
|
||||||
"variables": {"foo1": "bar1", "foo2": "bar2"},
|
"variables": {"foo1": "bar1", "foo2": "bar2"},
|
||||||
@@ -82,4 +82,4 @@ class TestCaseRequestWithVariables(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_start(self):
|
def test_start(self):
|
||||||
TestCaseRunner(self.config, self.teststeps).run()
|
HttpRunner(self.config, self.teststeps).run()
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from httprunner.runner import TestCaseRunner
|
from httprunner.runner import HttpRunner
|
||||||
from httprunner.schema import TestsConfig, TestStep
|
from httprunner.schema import TConfig, TStep
|
||||||
|
|
||||||
|
|
||||||
class TestCaseValidateWithFunctions(unittest.TestCase):
|
class TestCaseValidateWithFunctions(unittest.TestCase):
|
||||||
config = TestsConfig(
|
config = TConfig(
|
||||||
**{
|
**{
|
||||||
"name": "request methods testcase: validate with functions",
|
"name": "request methods testcase: validate with functions",
|
||||||
"variables": {"foo1": "session_bar1"},
|
"variables": {"foo1": "session_bar1"},
|
||||||
@@ -17,7 +17,7 @@ class TestCaseValidateWithFunctions(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
teststeps = [
|
teststeps = [
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "get with params",
|
"name": "get with params",
|
||||||
"variables": {
|
"variables": {
|
||||||
@@ -42,4 +42,4 @@ class TestCaseValidateWithFunctions(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_start(self):
|
def test_start(self):
|
||||||
TestCaseRunner(self.config, self.teststeps).run()
|
HttpRunner(self.config, self.teststeps).run()
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from httprunner.runner import TestCaseRunner
|
from httprunner.runner import HttpRunner
|
||||||
from httprunner.schema import TestsConfig, TestStep
|
from httprunner.schema import TConfig, TStep
|
||||||
|
|
||||||
|
|
||||||
class TestCaseValidateWithVariables(unittest.TestCase):
|
class TestCaseValidateWithVariables(unittest.TestCase):
|
||||||
config = TestsConfig(
|
config = TConfig(
|
||||||
**{
|
**{
|
||||||
"name": "request methods testcase: validate with variables",
|
"name": "request methods testcase: validate with variables",
|
||||||
"variables": {"foo1": "session_bar1"},
|
"variables": {"foo1": "session_bar1"},
|
||||||
@@ -17,7 +17,7 @@ class TestCaseValidateWithVariables(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
teststeps = [
|
teststeps = [
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "get with params",
|
"name": "get with params",
|
||||||
"variables": {"foo1": "bar1", "foo2": "session_bar2"},
|
"variables": {"foo1": "bar1", "foo2": "session_bar2"},
|
||||||
@@ -35,7 +35,7 @@ class TestCaseValidateWithVariables(unittest.TestCase):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "post raw text",
|
"name": "post raw text",
|
||||||
"variables": {"foo1": "hello world", "foo3": "$session_foo2"},
|
"variables": {"foo1": "hello world", "foo3": "$session_foo2"},
|
||||||
@@ -59,7 +59,7 @@ class TestCaseValidateWithVariables(unittest.TestCase):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestStep(
|
TStep(
|
||||||
**{
|
**{
|
||||||
"name": "post form data",
|
"name": "post form data",
|
||||||
"variables": {"foo1": "bar1", "foo2": "bar2"},
|
"variables": {"foo1": "bar1", "foo2": "bar2"},
|
||||||
@@ -82,4 +82,4 @@ class TestCaseValidateWithVariables(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_start(self):
|
def test_start(self):
|
||||||
TestCaseRunner(self.config, self.teststeps).run()
|
HttpRunner(self.config, self.teststeps).run()
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ from loguru import logger
|
|||||||
|
|
||||||
from httprunner import report, loader, utils, exceptions, __version__
|
from httprunner import report, loader, utils, exceptions, __version__
|
||||||
from httprunner.report import gen_html_report
|
from httprunner.report import gen_html_report
|
||||||
from httprunner.runner import TestCaseRunner
|
from httprunner.runner import HttpRunner as TestCaseRunner
|
||||||
from httprunner.schema import TestsMapping, TestCaseSummary, TestSuiteSummary
|
from httprunner.schema import TestsMapping, TestCaseSummary, TestSuiteSummary
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,26 +9,27 @@ from httprunner.new_loader import load_testcase_file, load_folder_files
|
|||||||
__TMPL__ = """# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
__TMPL__ = """# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from httprunner.runner import TestCaseRunner
|
from httprunner.runner import HttpRunner
|
||||||
from httprunner.schema import TestsConfig, TestStep
|
from httprunner.schema import TConfig, TStep
|
||||||
|
|
||||||
|
|
||||||
class {{ class_name }}(unittest.TestCase):
|
class {{ class_name }}(unittest.TestCase):
|
||||||
config = TestsConfig(**{{ config }})
|
config = TConfig(**{{ config }})
|
||||||
|
|
||||||
teststeps = [
|
teststeps = [
|
||||||
{% for teststep in teststeps %}
|
{% for teststep in teststeps %}
|
||||||
TestStep(**{{ teststep }}),
|
TStep(**{{ teststep }}),
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
|
|
||||||
def test_start(self):
|
def test_start(self):
|
||||||
TestCaseRunner(self.config, self.teststeps).run()
|
HttpRunner(self.config, self.teststeps).run()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def make_testcase(testcase_path: str) -> str:
|
def make_testcase(testcase_path: str) -> str:
|
||||||
|
logger.info(f"start to make testcase: {testcase_path}")
|
||||||
testcase, _ = load_testcase_file(testcase_path)
|
testcase, _ = load_testcase_file(testcase_path)
|
||||||
template = jinja2.Template(__TMPL__)
|
template = jinja2.Template(__TMPL__)
|
||||||
|
|
||||||
|
|||||||
@@ -10,18 +10,18 @@ from httprunner.new_loader import load_project_data, load_testcase_file
|
|||||||
from httprunner.parser import build_url, parse_data, parse_variables_mapping
|
from httprunner.parser import build_url, parse_data, parse_variables_mapping
|
||||||
from httprunner.response import ResponseObject
|
from httprunner.response import ResponseObject
|
||||||
from httprunner.schema import (
|
from httprunner.schema import (
|
||||||
TestsConfig,
|
TConfig,
|
||||||
TestStep,
|
TStep,
|
||||||
VariablesMapping,
|
VariablesMapping,
|
||||||
StepData,
|
StepData,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestCaseRunner(object):
|
class HttpRunner(object):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: TestsConfig,
|
config: TConfig,
|
||||||
teststeps: List[TestStep],
|
teststeps: List[TStep],
|
||||||
session: HttpSession = None,
|
session: HttpSession = None,
|
||||||
):
|
):
|
||||||
if not config.path:
|
if not config.path:
|
||||||
@@ -38,11 +38,11 @@ class TestCaseRunner(object):
|
|||||||
self.project_data = load_project_data(self.config.path)
|
self.project_data = load_project_data(self.config.path)
|
||||||
self.config.functions = self.project_data.functions
|
self.config.functions = self.project_data.functions
|
||||||
|
|
||||||
def with_variables(self, **variables: VariablesMapping) -> "TestCaseRunner":
|
def with_variables(self, **variables: VariablesMapping) -> "HttpRunner":
|
||||||
self.config.variables.update(variables)
|
self.config.variables.update(variables)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __run_step_request(self, step: TestStep):
|
def __run_step_request(self, step: TStep):
|
||||||
"""run teststep: request"""
|
"""run teststep: request"""
|
||||||
step_data = StepData(name=step.name)
|
step_data = StepData(name=step.name)
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ class TestCaseRunner(object):
|
|||||||
_, testcase_obj = load_testcase_file(ref_testcase_path)
|
_, testcase_obj = load_testcase_file(ref_testcase_path)
|
||||||
|
|
||||||
case_result = (
|
case_result = (
|
||||||
TestCaseRunner(testcase_obj.config, testcase_obj.teststeps, self.session)
|
HttpRunner(testcase_obj.config, testcase_obj.teststeps, self.session)
|
||||||
.with_variables(**step_variables)
|
.with_variables(**step_variables)
|
||||||
.run()
|
.run()
|
||||||
)
|
)
|
||||||
@@ -136,7 +136,7 @@ class TestCaseRunner(object):
|
|||||||
|
|
||||||
return step_data
|
return step_data
|
||||||
|
|
||||||
def __run_step(self, step: TestStep):
|
def __run_step(self, step: TStep):
|
||||||
"""run teststep, teststep maybe a request or referenced testcase"""
|
"""run teststep, teststep maybe a request or referenced testcase"""
|
||||||
logger.info(f"run step: {step.name}")
|
logger.info(f"run step: {step.name}")
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class MethodEnum(Text, Enum):
|
|||||||
TRACE = "TRACE"
|
TRACE = "TRACE"
|
||||||
|
|
||||||
|
|
||||||
class TestsConfig(BaseModel):
|
class TConfig(BaseModel):
|
||||||
name: Name
|
name: Name
|
||||||
verify: Verify = False
|
verify: Verify = False
|
||||||
base_url: BaseUrl = ""
|
base_url: BaseUrl = ""
|
||||||
@@ -58,7 +58,7 @@ class Request(BaseModel):
|
|||||||
verify: Verify = False
|
verify: Verify = False
|
||||||
|
|
||||||
|
|
||||||
class TestStep(BaseModel):
|
class TStep(BaseModel):
|
||||||
name: Name
|
name: Name
|
||||||
request: Request = None
|
request: Request = None
|
||||||
testcase: Text = ""
|
testcase: Text = ""
|
||||||
@@ -68,8 +68,8 @@ class TestStep(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class TestCase(BaseModel):
|
class TestCase(BaseModel):
|
||||||
config: TestsConfig
|
config: TConfig
|
||||||
teststeps: List[TestStep]
|
teststeps: List[TStep]
|
||||||
|
|
||||||
|
|
||||||
class ProjectMeta(BaseModel):
|
class ProjectMeta(BaseModel):
|
||||||
|
|||||||
Reference in New Issue
Block a user