当前位置:网站首页>Unittest框架的测试日志
Unittest框架的测试日志
2022-06-21 16:00:00 【爆肝拳专业户】
日志:通俗来讲就是历史记录
按照自己的需求,编写输出日志内容
案例代码:
import time
def test_log():
#创建log.txt文件,并将日志信息追加(a+)
file=open('./log.txt','a+')
#获取系统当前时间
sys_time=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
#获取当前函数名称
file_name= test_log.__name__
#组合一条信息
info = '['+ sys_time +']'+''+ file_name +''+'\n'
print(info)
#将info数据记录到log.txt文件中
file.write(info)
#关闭文件
file.close()
test_log()
运行结果:

边栏推荐
- Cloud native monitoring system - Nightingale's recent list of new functions to solve multiple production pain points
- 我给航母做3D还原:这三处细节,太震撼了…
- Ares Ares I pledged LP mining crowdfunding model DAPP smart contract customization
- [live broadcast preview] at 19:00 on June 24, hcsd live broadcast -- employment guide, which will take you through the interview points for the upcoming autumn recruitment and summer internship~~
- 好用不贵!11款开源自动化安全测试工具简介
- 快来围观–TPT18新版报到
- "Forget to learn again" shell process control - 36. Introduction to the for loop
- Esp8266 / esp32 obtenir la méthode NTP time via la Bibliothèque timelib
- Advanced performance test series 2. software performance test, load test and stress test
- addslashes,stripslashes
猜你喜欢

Serious illness insurance covers serious illness. Which product is the best in the market? Please recommend it

ESP8266/ESP32 通过TimeLib库获取NTP时间方法

Remote connection raspberry pie in VNC Viewer Mode

华为云发布桌面IDE-CodeArts

Cisco(59)——Hub&Spoke MPLS

Cloud native monitoring system - Nightingale's recent list of new functions to solve multiple production pain points

机器学习中的概念漂移(Aporia)

HUAWEI(13)——路由引入

Cisco(35)——BGP入门实验

The first atlas showing the development history of the database in China was officially released!
随机推荐
Web page automation practice 2. in elong, hotels are accurately matched according to city + date + keyword (Part 1)
云原生之混合云网络互联
如何判断DNS解析故障?如何解决DNS解析错误?
Huawei cloud releases desktop ide codearts
Necessary for data analysis: 6 steps +5 types +2 analysis methods
Do Internet companies do unit tests? Is it necessary to do unit testing for the needs of the bank?
Serious illness insurance covers serious illness. Which product is the best in the market? Please recommend it
In 2021 database market, aerospike competes with top manufacturers
Come and watch – tpt18 new report
What are the differences between SVN and VSS
addslashes,stripslashes
Web page automation practice 5. get the name, price and rating information of all hotels and write them into the file
D improve translation
快来围观–TPT18新版报到
Notice on printing and distributing the Interim Measures of Beijing Municipality for the administration of housing with common property rights
Disruptor local thread queue_ Workprocessor exception_ Fatalexceptionhandler--- inter thread communication work note 004
学习软件“学习通”数据库疑似发生信息泄露,泄露学生信息达1亿多条
我敢闯 我会创!第八届“互联网 +”大赛GaussDB命题开放报名啦!
Esp8266/esp32 get NTP time method through timelib Library
首批入围企业公示!年度TOP100智能网联供应商评选