当前位置:网站首页>Test log of unittest framework

Test log of unittest framework

2022-06-21 17:02:00 Expert of explosive liver fist

journal : Generally speaking, it is a historical record
According to your own needs , Write output log contents
Case code :

import time

def test_log():
    # establish log.txt file , And add the log information (a+)
    file=open('./log.txt','a+')

    # Get the current time of the system 
    sys_time=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())

    # Get the current function name 
    file_name= test_log.__name__

    # Combine one message 
    info = '['+ sys_time +']'+''+ file_name +''+'\n'
    print(info)

    # take info Data recorded to log.txt In file 
    file.write(info)

    # Close file 
    file.close()

test_log()

Running results :
 Insert picture description here
 Insert picture description here

原网站

版权声明
本文为[Expert of explosive liver fist]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211318465067.html