小编Raj*_*Raj的帖子

如何捕获 pytest-html 上的日志详细信息并写入控制台?

在我的 pytest 脚本中,我需要自定义pytest-HTML报告以捕获标准输出,同时写入控制台,因为我在自动化测试中有用户输入。

test_TripTick.py

import os
import sys
import pytest

from Process import RunProcess
from recordtype import recordtype
from pip._vendor.distlib.compat import raw_input

@pytest.fixture(scope="module")
def Process(request):
    # print('\nProcess setup - module fixture')
    fileDirectory = os.path.abspath(os.path.dirname(__file__))
    configFilePath = os.path.join(fileDirectory, 'ATR220_Config.json')
    process = RunProcess.RunProcess()
    process.SetConfigVariables(configFilePath)
    process.GetComPort(["list=PID_0180"])

    def fin():
        sys.exit()
        request.addfinalizer(fin)

    return process


def test_WipeOutReader(Process):
    assert Process.WipeOutTheReader() == True


def test_LoadingKeysIntoMemoryMap(Process):
    assert Process.LoadingKeysIntoMemoryMap() == True


def test_LoadingFW(Process):  # only use bar
    assert Process.LoadingFW() == True


def test_LoadingSBL(Process):
    assert Process.LoadingSBL() == True


def …
Run Code Online (Sandbox Code Playgroud)

console capture pytest-html

5
推荐指数
1
解决办法
9544
查看次数

标签 统计

capture ×1

console ×1

pytest-html ×1