- 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()
来源: http://www.bubuko.com/infodetail-3080826.html