fix: ensure generated conftest.py located in generated pytest folder

This commit is contained in:
debugtalk
2020-06-06 22:13:59 +08:00
parent e2703fff32
commit d29941124d
6 changed files with 74 additions and 70 deletions

View File

@@ -9,7 +9,7 @@ from loguru import logger
from httprunner import exceptions
from httprunner.loader import load_project_meta
from httprunner.utils import sort_dict_by_custom_order
from httprunner.utils import sort_dict_by_custom_order, ensure_file_path_valid
def convert_jmespath(raw: Text) -> Text:
@@ -221,6 +221,7 @@ def generate_conftest_for_summary(args: List):
project_meta = load_project_meta(test_path)
conftest_path = os.path.join(project_meta.RootDir, "conftest.py")
conftest_path = ensure_file_path_valid(conftest_path)
if os.path.isfile(conftest_path):
return
@@ -308,6 +309,10 @@ def session_fixture(request):
"{{SUMMARY_PATH_PLACEHOLDER}}", summary_path
)
dir_path = os.path.dirname(conftest_path)
if not os.path.exists(dir_path):
os.makedirs(dir_path)
with open(conftest_path, "w", encoding="utf-8") as f:
f.write(conftest_content)