首页 > 其他 > 详细

pytest demo and log format

时间:2019-06-02 21:46:38      阅读:138      评论:0      收藏:0      [点我收藏+]
import pytest
import allure
import sys,os
import logging
import datetime

def logInit():

    now_time = datetime.datetime.now()
    filePath = os.getcwd() + "\\log\\" 
    if os.path.exists(filePath) is False:
        os.makedirs(filePath)
    logFile = filePath + now_time.strftime("%Y%m%d_%H%M%S") +".log"

    logging.basicConfig(filename=logFile,
                        filemode="w",
                        format="%(asctime)s -- [line:%(lineno)d] -- %(levelname)s -- %(filename)s  -- %(message)s",
                        level=logging.DEBUG)


logInit()
@allure.feature(Manual overide testcase ) 
class TestStringMethods():

    @classmethod
    def setup_class(cls):
        logging.info("setup class")

    @classmethod
    def teardown_class(cls):
        logging.info("teardown class")
        
    @allure.feature(test_demo1)
    @allure.severity(blocker)
    def test_demo_0_1(self):
        a = 10
        b = 11
        assert a is not b
        logging.info("=================test_demo_0_1===============")

    @allure.feature(test_demo1)
    @allure.severity(blocker)
    def test_demo_0_2(self):
        a = 11
        b = 11
        assert a is b
        logging.error("assert a = %d is b = %d" %(a,b))

if __name__ == __main__:
    pytest.main()

 

pytest demo and log format

原文:https://www.cnblogs.com/mftang2018/p/10964490.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!