自定义最终部分中的pytest插件内容

发布于 2025-01-30 04:35:24 字数 956 浏览 3 评论 0原文

我正在使用pytest-rerunfailures插件来标记大型测试套件中的片状测试。我喜欢插件对输出格式进行的添加,因为测试执行:我可以看到每个测试的通过或失败时的状态,如果失败,我可以看到清晰标记的rerun nater lack通过下一个测试的尝试。这使得随着片状测试失败,然后重新运行变得容易进行。

pytest-rerunfailures在最终的“简短测试摘要信息”部分中未显示任何RERUN信息(除了最终摘要行(并未向您显示需要重新运行的测试> -ra 命令行选项,我在这里做过)​​:

”在此处输入图像描述

我想从测试运行末尾的第一部分中获取信息,所以我不知道必须滚动控制台中的页面和页面,以查看哪些测试是重新运行的。我一直在考虑在测试运行末尾创建一个自定义部分,基于我找到的答案在这里。使用该技巧,我可以打印出一个不错的自定义部分(即使以黄色为黄色,插件标记重新融合结果的颜色相同)。但是我似乎无法弄清楚如何提取我想要的信息:在哪些测试中进行了哪些测试以及哪些需要重新运行。

谁能伸出援手?预先感谢!

I'm using the pytest-rerunfailures plugin to mark flaky tests in a large test suite. I like the addition the plugin makes to the output format as tests execute: I can see each test's status as it passes or fails, and if it fails, I can see the clearly-marked RERUN designation, followed by the next attempt at that test. This makes it easy to follow along as flaky tests fail and then get rerun.

pytest console output as test is running

However, pytest-rerunfailures does not show any RERUN information in the final "short test summary info" section of the terminal output (except for the final summary line, which doesn't show you which tests needed to be rerun) - it only shows Pass/Fail/Skipped/Xfail/Xpass/Error/Warning results (true even if pytest is run with the -rA command line option, wihch I did here):

enter image description here

I'd like to have the information from the first section available at the end of the test run so I don't have to scroll back pages and pages in the console to see which tests were rerun. I was looking at creating into a custom section at the end of the test run, based on the answer I found here. Using that tip, I'm able to print out a nice custom section (even in yellow, the same color the plugin marks RERUN outcomes). But I can't seem to figure out how to pull in the information I want: which tests were run when, and which of those required a rerun.

Can anyone lend a helping hand? Thank in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黄昏下泛黄的笔记 2025-02-06 04:35:24

事实证明,如果您在运行时指定-rar选项,则确实会获取最终重播信息摘要部分。但是它是黑白的,并且不是“流”的,也不是初始测试会话开始部分。以与初始部分相同的方式介绍最终重新融资信息部分:颜色编码,并连续划定每个测试尝试,而不仅仅是一个测试需要重新运行的摘要。

It turns out that if you specify the -raR option when you run, you do get a final rerun info summary section. It's black and white though, and doesn't "flow" as well as the initial test session starts section. It would be clearer to present the final rerun info section in the same way as the initial section is presented: color-coded, and delineating each test attempt in succession, not just a summary of which tests required a rerun.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文