Merge pull request #369 from HttpRunner/bugfix

fix #368: failed to load .env data in debugtalk.py
This commit is contained in:
debugtalk
2018-08-31 16:46:47 +08:00
committed by GitHub
2 changed files with 10 additions and 4 deletions

View File

@@ -892,19 +892,23 @@ def load_project_tests(test_path):
load_builtin_module()
debugtalk_path = locate_debugtalk_py(test_path)
# locate PWD with debugtalk.py path
if debugtalk_path:
# The folder contains debugtalk.py will be treated as PWD.
# add PWD to sys.path
project_working_directory = os.path.dirname(debugtalk_path)
# load debugtalk.py
sys.path.insert(0, project_working_directory)
load_debugtalk_module()
else:
# debugtalk.py not found, use os.getcwd() as PWD.
project_working_directory = os.getcwd()
# load .env
load_dot_env_file()
# load debugtalk.py
if debugtalk_path:
sys.path.insert(0, project_working_directory)
load_debugtalk_module()
load_api_folder(os.path.join(project_working_directory, "api"))
# TODO: replace suite with testcases
load_test_folder(os.path.join(project_working_directory, "suite"))

View File

@@ -7,6 +7,8 @@ import time
from tests.api_server import HTTPBIN_SERVER, SECRET_KEY, gen_md5, get_sign
BASE_URL = "http://127.0.0.1:5000"
UserName = os.environ['UserName']
demo_default_request = {
"base_url": "$BASE_URL",