接口测试系列:工作中所用(八:读取配置文件 --settings.yml文件和数据库配置.yml文件)

base.py

import
os from common import fileUtil def __read_config(): base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) settings_file = os.path.join(os.path.join(os.path.realpath(base_dir), "config"), "settings.yml") db_file = os.path.join(os.path.join(os.path.realpath(base_dir), "config"), "db.yml") print(settings_file) settings = fileUtil().connect_to(settings_file).parsed_data db = fileUtil().connect_to(db_file).parsed_data ENV = settings["env"] source = settings["source"] return ENV, db, source, settings ENV, DB, dbc, settings = __read_config()
原文地址:https://www.cnblogs.com/by170628/p/10096653.html