mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +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")
|
||||
.base_url("https://postman-echo.com")
|
||||
.verify(False)
|
||||
.set_path(
|
||||
"examples/postman_echo/request_methods/request_with_functions_test.py"
|
||||
)
|
||||
)
|
||||
|
||||
teststeps = [
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Text, Any, Dict
|
||||
import inspect
|
||||
from typing import Text, Any
|
||||
|
||||
from httprunner.schema import (
|
||||
TConfig,
|
||||
@@ -14,7 +15,9 @@ class Config(object):
|
||||
self.__variables = {}
|
||||
self.__base_url = ""
|
||||
self.__verify = False
|
||||
self.__path = ""
|
||||
|
||||
caller_frame = inspect.stack()[1]
|
||||
self.__path = caller_frame.filename
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -36,10 +39,6 @@ class Config(object):
|
||||
self.__verify = verify
|
||||
return self
|
||||
|
||||
def set_path(self, path: Text) -> "Config":
|
||||
self.__path = path
|
||||
return self
|
||||
|
||||
def perform(self) -> TConfig:
|
||||
return TConfig(
|
||||
name=self.__name,
|
||||
@@ -171,4 +170,3 @@ class Step(object):
|
||||
extract=self.__extract,
|
||||
validate=self.__validators,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user