pytest-jequnauto/common/setting.py

27 lines
585 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/11/25 13:07
# @Author : 李晓杰
import os
from typing import Text
def root_path():
""" 获取 根路径 """
# F:\JACK\My_project\pytest-auto-api2
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
return path
def ensure_path_sep(path: Text) -> Text:
"""兼容 windows 和 linux 不同环境的操作系统路径 """
if "/" in path:
path = os.sep.join(path.split("/"))
if "\\" in path:
path = os.sep.join(path.split("\\"))
return root_path() + path