From af7ffc1de80a7f50e29919d3dbce26062a4a0b19 Mon Sep 17 00:00:00 2001 From: floraachy <1622042529@qq.com> Date: Wed, 17 May 2023 17:28:33 +0800 Subject: [PATCH] =?UTF-8?q?(2023-05-11)=20=E5=9C=A8=E9=92=A9=E5=AD=90?= =?UTF-8?q?=E5=87=BD=E6=95=B0pytest=5Fsessionfinish=E4=B8=AD=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=91=BD=E4=BB=A4=E8=A1=8C=E8=BE=93=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E2=80=93env=E7=9A=84=E5=8F=82=E6=95=B0=EF=BC=8C=E5=BD=93?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F=E6=B1=87?= =?UTF-8?q?=E4=B8=AD=E7=9A=84host=E8=AF=BB=E5=8F=96=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BD=BF=E7=94=A8=E2=80=93?= =?UTF-8?q?env=E5=AF=B9=E5=BA=94=E7=9A=84=E5=8F=82=E6=95=B0=E4=BD=9C?= =?UTF-8?q?=E4=B8=BA=E9=A1=B9=E7=9B=AE=E7=8E=AF=E5=A2=83=E7=9A=84=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conftest.py b/conftest.py index 9db0eec..eff8e6c 100644 --- a/conftest.py +++ b/conftest.py @@ -71,7 +71,6 @@ def pytest_runtest_makereport(item, call): # 获取调用结果的测试报告,返回一个report对象 # report对象的属性包括when(steup, call, teardown三个值)、nodeid(测试用例的名字)、outcome(用例的执行结果,passed,failed) report = outcome.get_result() - # TODO:由于目前无法动态将用例数据中的title写入测试方法中的文档注释,因此该处理方法暂时搁置 # 将测试方法的文档注释作为结果表的Description的值,如果文档注释为空,则测试方法名作为结果表的Description的值 report.description = str(item.function.__doc__) report.nodeid = report.nodeid.encode("utf-8").decode("unicode_escape") @@ -102,7 +101,8 @@ def pytest_sessionfinish(session, exitstatus): 在测试运行后,修改Environment部分信息 """ # 给环境表 添加 项目环境 - session.config._metadata['项目环境'] = GLOBAL_VARS.get("host", "") + env = session.config.getoption("--env") # 可以获取到命令行参数指定的环境 + session.config._metadata['项目环境'] = {GLOBAL_VARS.get("host", env)} @pytest.hookimpl(hookwrapper=True)