测试用例日志模块编写:

import time
#定义Loginfo类
class Loginfo(object):
#定义打开日志功能:
def __init__(self,path = "",mode = "w"):
fname = path + time.strftime("%Y-%m-%d",time.gmtime())
self.log = open(path + fname + ".txt",mode,encoding="utf-8")
#定义写日志功能:
def log_write(self,msg):
self.log.write(msg)
#定义关闭日志功能:
def log_close(self):
self.log.close()
if __name__ == '__main__':
log = Loginfo()
log.log_write("test Loginfo 测试")
log.log_close()

猜你喜欢

转载自www.cnblogs.com/zhang-da/p/12082566.html