测试完成后发送一个桌面测试和一个插件的声音播放通知
pytest-notification的Python项目详细描述
Pytest通知
pytest的一个插件,它在传递--notify标志时发送通知 在命令行上执行pytest。{a$或tt2播放时 --play-sound标志已传递。在
通知和声音根据测试运行是否 通过或失败。在
只有在传递标志时才会播放消息和声音。这允许 你只为那些你期待很长时间的测试打开它 需要。在
备选方案
pytest-notifier总是发送 通知。它可以用--notify-off打开。这是一个 根本不同的设计选择,这就是为什么创建这个包。 Pytest通知程序已经存在很长时间了,并且仍然处于活动状态 保持。它不支持播放声音,但它支持macosx 通知。在
使用
option | usage |
---|---|
^{tt1}$ | Sends a desktop notification when pytest is finished. (Only implemented on Linux. Requires the ‘notify-send’ program in PATH on Linux. |
^{tt2}$, ^{tt3}$ | Plays a sound when pytest is finished. (Only implemented on Linux and Macintosh systems). |
^{tt8}$ | shorthand for ^{tt9}$ |
安装
pytest通知可以与pip install pytest-notification一起安装。在
Linux
在Linux上,通过notify-send程序支持通知。德比安, Ubuntu及其派生发行版在libnotify-bin包中提供。在
在Linux上,通过paplay程序支持声音。在Debian、Ubuntu和 派生发行版可以在pulseaudio-utilspackage中找到。在
Ubuntu的安装应该是:
sudo apt update sudo apt install libnotify-bin pulseaudio-utils pip install pytest-notification
Mac OS X
在macosx上,声音是通过afplay程序实现的,它应该是 默认安装。因为我没有mac电脑,所以我无法测试这个功能。 欢迎拉取请求。在
在Mac OS X上不支持通知。 或者,您可以看看pytest-notifier,它确实支持macosx
Windows
不支持Windows。在
贡献
欢迎请求改进Mac和Windows支持。以及想法 以及其他请求。只需在github page上创建一个新问题或公关。在
Windows支持
理论上,winsound模块可以用来 播放声音,但这只支持wave文件。这些非常大而且 分发起来很麻烦。我没有积极地寻找一种方法来创建 windows上的消息。可能会有一些powershell命令可以 把这个拉下来。欢迎拉取请求。在
- 项目
标签: