mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
bugfix #35: load YAML/JSON config base_url as locust host
This commit is contained in:
+5
-1
@@ -3,6 +3,7 @@ import multiprocessing
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from ate.utils import load_testcases_by_path
|
||||||
from locust.main import main
|
from locust.main import main
|
||||||
|
|
||||||
|
|
||||||
@@ -35,10 +36,13 @@ def gen_locustfile(testcase_file_path):
|
|||||||
os.path.dirname(os.path.realpath(__file__)),
|
os.path.dirname(os.path.realpath(__file__)),
|
||||||
'locustfile_template'
|
'locustfile_template'
|
||||||
)
|
)
|
||||||
|
testsets = load_testcases_by_path(testcase_file_path)
|
||||||
|
host = testsets[0].get("config", {}).get("request", {}).get("base_url", "")
|
||||||
|
|
||||||
with codecs.open(template_path, encoding='utf-8') as template:
|
with codecs.open(template_path, encoding='utf-8') as template:
|
||||||
with codecs.open(locustfile_path, 'w', encoding='utf-8') as locustfile:
|
with codecs.open(locustfile_path, 'w', encoding='utf-8') as locustfile:
|
||||||
template_content = template.read()
|
template_content = template.read()
|
||||||
template_content = template_content.replace("$HOST", "https://skypixel.com")
|
template_content = template_content.replace("$HOST", host)
|
||||||
template_content = template_content.replace("$TESTCASE_FILE", testcase_file_path)
|
template_content = template_content.replace("$TESTCASE_FILE", testcase_file_path)
|
||||||
locustfile.write(template_content)
|
locustfile.write(template_content)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user