mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 03:30:01 +08:00
refactor: get config path with inspect stack
This commit is contained in:
@@ -10,9 +10,6 @@ class TestCaseRequestWithFunctions(HttpRunner):
|
|||||||
.variables(foo1="session_bar1")
|
.variables(foo1="session_bar1")
|
||||||
.base_url("https://postman-echo.com")
|
.base_url("https://postman-echo.com")
|
||||||
.verify(False)
|
.verify(False)
|
||||||
.set_path(
|
|
||||||
"examples/postman_echo/request_methods/request_with_functions_test.py"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
teststeps = [
|
teststeps = [
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from typing import Text, Any, Dict
|
import inspect
|
||||||
|
from typing import Text, Any
|
||||||
|
|
||||||
from httprunner.schema import (
|
from httprunner.schema import (
|
||||||
TConfig,
|
TConfig,
|
||||||
@@ -14,7 +15,9 @@ class Config(object):
|
|||||||
self.__variables = {}
|
self.__variables = {}
|
||||||
self.__base_url = ""
|
self.__base_url = ""
|
||||||
self.__verify = False
|
self.__verify = False
|
||||||
self.__path = ""
|
|
||||||
|
caller_frame = inspect.stack()[1]
|
||||||
|
self.__path = caller_frame.filename
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@@ -36,10 +39,6 @@ class Config(object):
|
|||||||
self.__verify = verify
|
self.__verify = verify
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def set_path(self, path: Text) -> "Config":
|
|
||||||
self.__path = path
|
|
||||||
return self
|
|
||||||
|
|
||||||
def perform(self) -> TConfig:
|
def perform(self) -> TConfig:
|
||||||
return TConfig(
|
return TConfig(
|
||||||
name=self.__name,
|
name=self.__name,
|
||||||
@@ -171,4 +170,3 @@ class Step(object):
|
|||||||
extract=self.__extract,
|
extract=self.__extract,
|
||||||
validate=self.__validators,
|
validate=self.__validators,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user