在我的 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 test_CCIDReadForPaymentCards(Process):
assert Process.CCIDReadWrite('Payment Card') == True
目前,如果我从 Windows 命令行运行以下命令,我会在控制台上获得输出,但在HTML report
.
pytest C:\Projects\TripTickAT\test_TripTick.py -s --html=Report.html --verbose
另外,我想知道自定义HTML report
可以更新file name
,ordering test based on time of the execution
和capturing the std-out
.