mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-14 01:49:41 +08:00
change: make FROM path in testcase notes relative to project_meta.RootDir
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.0.13
|
||||
# FROM: examples/httpbin/basic.yml
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: basic.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.0.13
|
||||
# FROM: examples/httpbin/hooks.yml
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: hooks.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.0.13
|
||||
# FROM: examples/httpbin/load_image.yml
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: load_image.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.0.13
|
||||
# FROM: examples/httpbin/upload.yml
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: upload.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.0.13
|
||||
# FROM: examples/httpbin/validate.yml
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: validate.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: examples/postman_echo/request_methods/request_with_functions.yml
|
||||
# FROM: request_methods/request_with_functions.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: examples/postman_echo/request_methods/request_with_testcase_reference.yml
|
||||
# FROM: request_methods/request_with_testcase_reference.yml
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: examples/postman_echo/request_methods/hardcode.yml
|
||||
# FROM: request_methods/hardcode.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: examples/postman_echo/request_methods/request_with_functions.yml
|
||||
# FROM: request_methods/request_with_functions.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: examples/postman_echo/request_methods/request_with_testcase_reference.yml
|
||||
# FROM: request_methods/request_with_testcase_reference.yml
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: examples/postman_echo/request_methods/request_with_variables.yml
|
||||
# FROM: request_methods/request_with_variables.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: examples/postman_echo/request_methods/validate_with_functions.yml
|
||||
# FROM: request_methods/validate_with_functions.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: Generated By HttpRunner v3.1.0
|
||||
# FROM: examples/postman_echo/request_methods/validate_with_variables.yml
|
||||
# FROM: request_methods/validate_with_variables.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
@@ -101,6 +101,26 @@ def __ensure_cwd_relative(path: Text) -> Text:
|
||||
return path
|
||||
|
||||
|
||||
def __convert_relative_project_root_dir(abs_path: Text) -> Text:
|
||||
""" convert absolute path to relative path, based on project_meta.RootDir
|
||||
|
||||
Args:
|
||||
abs_path: absolute path
|
||||
|
||||
Returns: relative path based on project_meta.RootDir
|
||||
|
||||
"""
|
||||
project_meta = load_project_meta(abs_path)
|
||||
if not abs_path.startswith(project_meta.RootDir):
|
||||
raise exceptions.ParamsError(
|
||||
f"failed to convert absolute path to relative path based on project_meta.RootDir\n"
|
||||
f"abs_path: {abs_path}\n"
|
||||
f"project_meta.RootDir: {project_meta.RootDir}"
|
||||
)
|
||||
|
||||
return abs_path[len(project_meta.RootDir) + 1 :]
|
||||
|
||||
|
||||
def __ensure_testcase_module(path: Text) -> NoReturn:
|
||||
""" ensure pytest files are in python module, generate __init__.py on demand
|
||||
"""
|
||||
@@ -331,7 +351,7 @@ def make_testcase(testcase: Dict, dir_path: Text = None) -> Text:
|
||||
return testcase_python_path
|
||||
|
||||
config = testcase["config"]
|
||||
config["path"] = __ensure_cwd_relative(testcase_python_path)
|
||||
config["path"] = __convert_relative_project_root_dir(testcase_python_path)
|
||||
config["variables"] = convert_variables(
|
||||
config.get("variables", {}), testcase_abs_path
|
||||
)
|
||||
@@ -370,7 +390,7 @@ def make_testcase(testcase: Dict, dir_path: Text = None) -> Text:
|
||||
|
||||
data = {
|
||||
"version": __version__,
|
||||
"testcase_path": __ensure_cwd_relative(testcase_abs_path),
|
||||
"testcase_path": __convert_relative_project_root_dir(testcase_abs_path),
|
||||
"class_name": f"TestCase{testcase_cls_name}",
|
||||
"imports_list": imports_list,
|
||||
"config_chain_style": make_config_chain_style(config),
|
||||
|
||||
Reference in New Issue
Block a user