refactor: get config path with inspect stack

This commit is contained in:
debugtalk
2020-06-01 16:55:36 +08:00
parent 2b30a1337b
commit a465906626
2 changed files with 5 additions and 10 deletions

View File

@@ -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 = [

View File

@@ -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,
)