码迷,mamicode.com
首页 > 其他好文 > 详细

pytest demo and log format

时间:2019-06-02 21:44:36      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:pat   case   rdo   mes   message   methods   init   cti   method   

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

标签:pat   case   rdo   mes   message   methods   init   cti   method   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!