pytest插件_Pytest插件来爱❤️

pytest插件

Pytest is extensible and has plenty of plugins. You don’t need to use any of them, but you might find some very useful. I love this because you have an easy time to get started with unit testing, while still finding amazing stuff when you’re more experienced 🤩

Pytest是可扩展的,并且具有许多插件。 您不需要使用它们中的任何一个,但是您可能会发现它们非常有用。 我之所以喜欢它,是因为您有一个轻松的时间开始进行单元测试 ,而当您更有经验时仍然可以找到很棒的东西🤩

In this article, I’ll show you examples of plugins I use and the plugins I found while writing this article. You might want to cover the basics of unit testing first or refresh testing details like fixtures.

在本文中,我将向您展示我使用的插件示例以及在撰写本文时发现的插件。 您可能需要先介绍单元测试基础知识,或刷新诸如Fixtures之类的测试详细信息

如何添加插件? (How can I add a plugin?)

All plugins presented in this article can be installed via pip . Most of them are then already active. For example, when you install pytest-sugar via

本文介绍的所有插件都可以通过pip安装。 然后,其中大多数已经处于活动状态。 例如,当您通过以下方式安装pytest-sugar时

pip install pytest-sugar

You can just execute pytest and the plugin will automatically work. Others need to be used more directly. For example, after installing pytest-timeout you need to specify the timeout parameter you want to use:

您只需执行pytest ,插件就会自动运行。 其他的则需要更直接地使用。 例如,在安装pytest-timeout您需要指定要使用的timeout参数:

pytest --timeout=1

Don’t worry, I will explain those two plugins later 🙂

不用担心,我稍后会解释这两个插件🙂

有多少个Pytest插件? (How many Pytest plugins exist?)

Searching on pypi.org for the trove classifier Framework :: Pytest , I found 668 packages. A stunning 1053 packages have “pytest” in the name. 461 packages have both, the name and the trove classifier.

在pypi.org上搜索trove分类器Framework :: Pytest ,我发现了668个软件包。 令人惊叹的1053软件包名称中带有“ pytest”。 461个程序包同时包含名称和旅行分类器。

I went through over 700 pytest-plugins for this article. I’ve jumped over plugins that consider themselves to be in planning, pre-alpha, or alpha stage. I’ve also skipped packages where I’ve seen a TODO in the readme or if the package had less than 10 stars on GitHub.

本文涉及700多个pytest插件。 我跳过了认为自己处于计划,预Alpha或Alpha阶段的插件。 我还跳过了在自述文件中看到TODO软件包,或者如果该软件包在GitHub上的星标不足10个,则会跳过这些软件包。

The packages I’ve found make pytest sparkle ✨, improve the speed 🏎, are specialized to specific packages, or just unique in their behavior ❄️

我发现的软件包会使pytest闪烁spark,提高速度🏎,专门针对特定的软件包,或者只是行为独特❄️

Last but not least, there are some plugins where I’m not sure if they are awesome or if they are a bad idea. Let’s jump right into it and have a look yourself!

最后但并非最不重要的一点是,在某些插件中,我不确定它们是否很棒或不是一个好主意。 让我们跳进去看看自己吧!

Side note: Maybe you remember my side note on typo squatting? I found a fixable issue on PyPI while writing this article, hopefully improving security for the community🎉

旁注 :也许您还记得我关于错字蹲的旁注 ? 在撰写本文时,我在PyPI上发现了一个可修复的问题 ,希望能改善社区的安全性🎉

闪亮的 (The shiny ones)

Image for post
Photo by Jeremy Thomas on Unsplash
杰里米·托马斯 ( Jeremy Thomas)摄影: Unsplash

The default output of pytest is already good, but some plugins make it amazing. pytest-sugar is one of those plugins❤

pytest的默认输出已经不错,但是一些插件使它变得惊人。 pytest-sugar是其中的一个插件❤

Image for post
Pytest sugar changes the dots to checkmarks and the percentage to a bar. Image by Martin Thoma.
Pytest糖将点更改为选中标记,将百分比更改为条形。 图片由Martin Thoma提供。

If those dots or checkmarks are too decent for you, givepytest-emoji and pytest-emoji-out a try 😃

如果这些点或复选标记对您来说太合适了,请

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值