pytest框架

1.添加日志

import logging

logging.debug('This is debug message')
logging.info('This is info message')
logging.warning('This is warning message')
import logging

logging.basicConfig(level=logging.DEBUG)

def test_1():
    log = logging.getLogger('test_1')
    time.sleep(1)
    log.debug('after 1 sec')
    time.sleep(1)
    log.debug('after 2 sec')
    time.sleep(1)
    log.debug('after 3 sec')
    assert 1, 'should pass'

2.代码覆盖率

安装

pip install pytest-cover

 

posted @ 2020-08-18 17:51  程程111  阅读(110)  评论(0编辑  收藏  举报