We're sunsetting PodQuest on 2025-07-28. Thank you for your support!
Export Podcast Subscriptions
cover of episode pytest-metadata - provides access to test session metadata

pytest-metadata - provides access to test session metadata

2025/5/8
logo of podcast Test & Code

Test & Code

AI Deep Dive Transcript
People
主持人
专注于电动车和能源领域的播客主持人和内容创作者。
Topics
主持人:pytest-metadata 是一个非常有用的 pytest 插件,它允许访问测试会话的元数据。这个插件本身就很有用,即使你已经安装了 pytest-html(它依赖于 pytest-metadata)。 pytest-metadata 默认情况下会添加 Python 版本、平台、已安装的包和插件等信息到测试输出的头部。你可以通过命令行参数 `--metadata` 添加自定义元数据,例如在 CI 环境中添加测试环境信息。你也可以通过 JSON 文件或 fixture 来添加元数据。 你可以通过多种方式读取元数据:直接在 pytest 输出中查看,导出到 JUnit XML 或 JSON 文件,或者在 pytest-html 生成的 HTML 报告中查看。一些其他插件,例如 pytest-base-url、pytest-selenium 和 pytest-reporter-html1,也会向 pytest-metadata 添加元数据。 pytest-metadata 对于在 CI 系统中传递额外的测试信息非常有用,因为它可以方便地将额外的信息与测试结果一起传递到 CI 管道中。

Deep Dive

Shownotes Transcript

pytest-metadata is described as a plugin for pytest that provides access to test session metadata. That is such a humble description for such a massively useful plugin. If you're already using pytest-html, you have pytest-metadata already installed, as pytest-metadata is one of the dependencies for pytest-html.However, pytest-metadata is very useful even on its own.

Links:

If you've got other plugins that work well with pytest-metadata, please let me know).

**Sponsored by: **

**Help support the show AND learn pytest: **

  • The Complete pytest course) is now a bundle, with each part available separately.

  • pytest Primary Power) teaches the super powers of pytest that you need to learn to use pytest effectively.

  • Using pytest with Projects) has lots of "when you need it" sections like debugging failed tests, mocking, testing strategy, and CI

  • Then pytest Booster Rockets) can help with advanced parametrization and building plugins.

  • Whether you need to get started with pytest today, or want to power up your pytest skills, PythonTest) has a course for you.

** ★ Support this podcast on Patreon ★) **