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