妗嗘灦鍋ュ.鎬т紭鍖栵紝鐜鍙橀噺绫伙紝姝e垯鏇挎崲excel
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了妗嗘灦鍋ュ.鎬т紭鍖栵紝鐜鍙橀噺绫伙紝姝e垯鏇挎崲excel相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e6%9d%a1%e4%bb%b6' title='鏉′欢'>鏉′欢
test header 姝e垯 preview common 瀵硅薄 杩囩▼ headers椤圭洰鍋ュ.鎬ф彁楂?path鍙傛暟鍖?/h1>
import os
# 鑾峰彇椤圭洰鎵€鍦ㄧ殑缁濆璺緞
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 鐢ㄤ緥妯″潡鎵€鍦ㄧ殑鐩綍璺緞
CASE_DIR = os.path.join(BASE_DIR, "testcases")
# 鐢ㄤ緥鏁版嵁鎵€鍦ㄧ殑鐩綍璺緞
DATA_DIR = os.path.join(BASE_DIR, "data")
# 閰嶇疆鏂囦欢鎵€鍦ㄧ殑鐩綍璺緞
CONF_DIR = os.path.join(BASE_DIR, "conf")
# 娴嬭瘯鎶ュ憡鎵€鍦ㄧ殑鐩綍璺緞
REPORT_DIR = os.path.join(BASE_DIR, "reports")
# 鏃ュ織鏂囦欢鎵€鍦ㄧ殑鐩綍璺緞
LOG_DIR = os.path.join(BASE_DIR, "logs")
寮曞叆姝e垯鏂逛究瀵筫xcel涓殑鏁版嵁鐏垫椿鏇挎崲瀹屽杽鍙傛暟鍖栨晥鏋?/h1>
import re
from common.handle_config import conf
class EnvData:
"""瀹氫箟涓€涓被锛岀敤鏉ヤ繚瀛樼敤渚嬫墽琛岃繃绋嬩腑锛屾彁鍙栧嚭鏉ョ殑鏁版嵁锛堝綋鎴愮幆澧冨彉閲忕殑瀹瑰櫒锛?""
pass
def replace_data(data):
"""鏇挎崲鏁版嵁"""
while re.search("#(.*?)#", data):
res = re.search("#(.*?)#", data)
# 杩斿洖鐨勫紡涓€涓尮閰嶅璞? # 鑾峰彇鍖归厤鍒扮殑鏁版嵁
key = res.group()
# 鑾峰彇鍖归厤瑙勫垯涓嫭鍙烽噷闈㈢殑鍐呭
item = res.group(1)
try:
# 鑾峰彇閰嶇疆鏂囦欢涓搴旂殑鍊? value = conf.get("test_data", item)
except:
# 鍘籈nvData杩欎釜绫婚噷闈㈣幏鍙栧搴旂殑灞炴€э紙鐜鍙橀噺锛? value = getattr(EnvData, item)
data = data.replace(key, value)
return data
鐜鍙橀噺绫荤殑瀹為檯搴旂敤
import os
# 鑾峰彇椤圭洰鎵€鍦ㄧ殑缁濆璺緞
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 鐢ㄤ緥妯″潡鎵€鍦ㄧ殑鐩綍璺緞
CASE_DIR = os.path.join(BASE_DIR, "testcases")
# 鐢ㄤ緥鏁版嵁鎵€鍦ㄧ殑鐩綍璺緞
DATA_DIR = os.path.join(BASE_DIR, "data")
# 閰嶇疆鏂囦欢鎵€鍦ㄧ殑鐩綍璺緞
CONF_DIR = os.path.join(BASE_DIR, "conf")
# 娴嬭瘯鎶ュ憡鎵€鍦ㄧ殑鐩綍璺緞
REPORT_DIR = os.path.join(BASE_DIR, "reports")
# 鏃ュ織鏂囦欢鎵€鍦ㄧ殑鐩綍璺緞
LOG_DIR = os.path.join(BASE_DIR, "logs")
import re
from common.handle_config import conf
class EnvData:
"""瀹氫箟涓€涓被锛岀敤鏉ヤ繚瀛樼敤渚嬫墽琛岃繃绋嬩腑锛屾彁鍙栧嚭鏉ョ殑鏁版嵁锛堝綋鎴愮幆澧冨彉閲忕殑瀹瑰櫒锛?""
pass
def replace_data(data):
"""鏇挎崲鏁版嵁"""
while re.search("#(.*?)#", data):
res = re.search("#(.*?)#", data)
# 杩斿洖鐨勫紡涓€涓尮閰嶅璞? # 鑾峰彇鍖归厤鍒扮殑鏁版嵁
key = res.group()
# 鑾峰彇鍖归厤瑙勫垯涓嫭鍙烽噷闈㈢殑鍐呭
item = res.group(1)
try:
# 鑾峰彇閰嶇疆鏂囦欢涓搴旂殑鍊? value = conf.get("test_data", item)
except:
# 鍘籈nvData杩欎釜绫婚噷闈㈣幏鍙栧搴旂殑灞炴€э紙鐜鍙橀噺锛? value = getattr(EnvData, item)
data = data.replace(key, value)
return data
鐜鍙橀噺绫荤殑瀹為檯搴旂敤
瀹炰緥浠g爜