config.py
作者:互联网
import os
from configparser import ConfigParser
class Config():
path_config=os.path.join(os.path.dirname(__file__),'config.ini')
#section
section_baidu='baidu'
section_sogou='sogou'
section_dbshop='dbshop'
#option
option_tester='tester'
option_env='environment'
option_versioncode='vresioncode'
option_host='host'
option_apikey='apikey'
def __init__(self):
self.config=ConfigParser()
self.config.read(Config.path_config,encoding='utf-8')
#baidu
self.env_baidu=self.config.get(Config.section_baidu,Config.option_env)
self.versioncode_baidu=self.config.get(Config.section_baidu,Config.option_versioncode)
self.host_baidu=self.config.get(Config.section_baidu,Config.option_host)
#sogou
self.env_sogou=self.config.get(Config.section_sogou,Config.option_env)
self.versioncode_sogou=self.config.get(Config.section_sogou,Config.option_versioncode)
self.host_sogou=self.config.get(Config.section_sogou,Config.option_host)
#print(Config().apikey_dbshop)
class TestData_Init():
@staticmethod
def get_test_data():
env_baidu = Config().env_baidu
versioncode_baidu = Config().versioncode_baidu
host_baidu = Config().host_baidu
env_sogou = Config().env_sogou
versioncode_sogou = Config().versioncode_sogou
host_sogou = Config().host_sogou
g=globals()
#运行百度
#return env_baidu,versioncode_baidu,host_baidu
#运行搜狗
return env_sogou,versioncode_sogou,host_sogou
#全部可以运行
#return host_sogou,host_baidu
print(TestData_Init.get_test_data())
标签:baidu,config,self,py,sogou,host,Config 来源: https://www.cnblogs.com/portal7282/p/15993219.html