A package that assists in writing tests for discord.py
Project description
dpytest
This is a package to allow testing of discord.py. It is only compatible with the rewrite version, and is still in early alpha. It relies on pytest-asyncio for asynchronous test running, as discord.py is coroutine driven.
Documentation
Documentation can be found at dpytest.readthedocs.io, including examples and tutorials
Usage
TODO: Move this to RTD
dpytest can be used for projects using the default commands.Bot, or those defining their own subclass of bot. For someone using a custom class, code would look something like this:
import discord.ext.test as dpytest
import yourbot
import pytest
@pytest.mark.asyncio
async def test_bot():
bot = yourbot.BotClass()
# Load any extensions/cogs you want to in here
dpytest.configure(bot)
await dpytest.message("!help")
dpytest.verify_message("[Expected help output]")
The dpytest framework is designed to be used best with pytest style fixtures, but is technically framework agnostic.
With pytest, the bot setup step would be moved into a fixture so each test could use that fixture. Configure will ensure
that all state is reset after each call.
History
0.1.1
- Add content type to attachments
- Overwrite _guild_needs_chunking (fix for asyncio wait_for errors)
0.1.0
- Bump version (sould have done that with 0.0.23, since many changes have been commited)
- Bug fix with role_mentions=None being not iterable.
0.0.23
- Support for discord.py 1.7.1
- Attachments allowed on messages
- verify_embed without test fixed
- Add members intent
- Added more testing
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.