Skip to main content

A pytest plugin to notify test results to a Discord channel.

Project description

.. contents:: **pytest-discord**
:backlinks: top
:depth: 2


Summary
============================================
.. image:: https://badge.fury.io/py/pytest-discord.svg
:target: https://badge.fury.io/py/pytest-discord
:alt: PyPI package version

.. image:: https://img.shields.io/pypi/pyversions/pytest-discord.svg
:target: https://pypi.org/project/pytest-discord
:alt: Supported Python versions

.. image:: https://img.shields.io/pypi/implementation/pytest-discord.svg
:target: https://pypi.org/project/pytest-discord
:alt: Supported Python implementations

.. image:: https://img.shields.io/travis/thombashi/pytest-discord/master.svg?label=Linux/macOS%20CI
:target: https://travis-ci.org/thombashi/pytest-discord
:alt: Linux/macOS CI status

.. image:: https://img.shields.io/appveyor/ci/thombashi/pytest-discord/master.svg?label=Windows%20CI
:target: https://ci.appveyor.com/project/thombashi/pytest-discord/branch/master
:alt: Windows CI status

A pytest plugin to notify test results to a Discord channel.


Installation
============================================
::

pip install pytest-discord


Quick start
============================================

Making a Discord webhook
--------------------------------------------
https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks


Usage
--------------------------------------------
Set a webhook URL when executing ``pytest`` via ``--discord-webhook`` option:

::

$ pytest --discord-webhook=<https://discordapp.com/api/webhooks/...>

.. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytest-discord@master/ss/pytest-discord.png
:scale: 80%
:alt: https://github.com/thombashi/pytest-discord/blob/master/ss/pytest-discord.png

Notification message example

Or, set a webhook URL to an environment variable ``PYTEST_DISCORD_WEBHOOK``:

::

$ export PYTEST_DISCORD_WEBHOOK=<https://discordapp.com/api/webhooks/...>
$ pytest

Or, you can specify webhook URL of a discord channel via ini-options (described later).


Increse the verbosity level
--------------------------------------------
::

$ pytest --discord-verbose=1

.. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytest-discord@master/ss/pytest-discord_verbose.png
:scale: 80%
:alt: https://github.com/thombashi/pytest-discord/blob/master/ss/pytest-discord_verbose.png

Notification message example

Notification messages may omit information caused by Discord limitations (especially when errors occurred).
You can get full messages as an attached markdown file with ``--discord-attach-file`` option


Options
============================================

Command options
--------------------------------------------
::

notify test results to a discord channel:
--discord-webhook=WEBHOOK_URL
discord webhook url of a discord channel to notify
pytest results. you can also specify the value with
PYTEST_DISCORD_WEBHOOK environment variable.
--discord-verbose=VERBOSITY_LEVEL
verbosity level for pytest-discord. if not set, using
verbosity level of pytest.
defaults to 0.
you can also specify the value with
PYTEST_DISCORD_VERBOSE environment variable.
--discord-username=DISCORD_USERNAME
name for a message. defaults to pytest-discord. you can
also specify the value with PYTEST_DISCORD_USERNAME
environment variable.
--discord-success-icon=ICON_URL
url to an icon of a successful run. you can also specify
the value with PYTEST_DISCORD_SUCCESS_ICON environment
variable.
--discord-skip-icon=ICON_URL
url to an icon of a skipped run. you can also specify
the value with PYTEST_DISCORD_SKIP_ICON environment
variable.
--discord-fail-icon=ICON_URL
url to an icon of a failed run. you can also specify the
value with PYTEST_DISCORD_FAIL_ICON environment
variable.
--discord-attach-file
post pytest results as a markdown file to a discord
channel. you can also specify the value with
PYTEST_DISCORD_ATTACH_FILE environment variable.


ini-options
--------------------------------------------
[pytest] ini-options in the first ``pytest.ini``/``tox.ini``/``setup.cfg``/``pyproject.toml (pytest 6.0.0 or later)`` file found:

::

discord_webhook (string):
discord webhook url of a discord channel to notify
pytest results.
discord_verbose (string):
verbosity level for pytest-discord. if not set, using
verbosity level of pytest. defaults to 0.
discord_username (string):
name for a message. defaults to pytest-discord.
discord_success_icon (string):
url to an icon of a successful run.
discord_skip_icon (string):
url to an icon of a skipped run.
discord_fail_icon (string):
url to an icon of a failed run.
discord_attach_file (bool):
post pytest results as a markdown file to a discord
channel.

:Example of ``pyproject.toml``:
.. code-block:: toml

[tool.pytest.ini_options]
discord_webhook = "https://discordapp.com/api/webhooks/..."
md_report_verbose = 1

:Example of ``setup.cfg``:
.. code-block:: ini

[tool:pytest]
discord_webhook = https://discordapp.com/api/webhooks/...
md_report_verbose = 1


Dependencies
============================================
- Python 3.5+
- `Python package dependencies (automatically installed) <https://github.com/thombashi/pytest-discord/network/dependencies>`__


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-discord-0.0.3.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_discord-0.0.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest-discord-0.0.3.tar.gz.

File metadata

  • Download URL: pytest-discord-0.0.3.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.6

File hashes

Hashes for pytest-discord-0.0.3.tar.gz
Algorithm Hash digest
SHA256 94a1f19b831310b9292d8e67d4fcafa27201cca70568e033281a78dc3a5fff90
MD5 90d58ffc00a47afe3a14506e328e6404
BLAKE2b-256 59cd23e5cb428c86f68930d55cecd80128eb5f844ad6659d7b5235a8f0757faa

See more details on using hashes here.

File details

Details for the file pytest_discord-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pytest_discord-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.6

File hashes

Hashes for pytest_discord-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2cae09fbe65477c933df7852f691846b41467f9e0238209356770093e27f511d
MD5 c90403645d208590c10b9c8eeb606caa
BLAKE2b-256 9b0c641cca5b48c83d9e9870388e2965ae4c8353d6a5641fbf41d4f2fd1b3e83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page