You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sergeileduc 87e8793c50 Bump version: 0.1.0 → 0.1.1 1 week ago
.github Github action "release on tag" 2 weeks ago
discord/ext/test Bump version: 0.1.0 → 0.1.1 1 week ago
docs Add missing module autodocs 10 months ago
tests Add content type to attachments 1 week ago
.gitignore Makefile file for 'invoke' tool (tasks.py) 2 weeks ago
.readthedocs.yml Add sphinx version requirement 1 year ago
.travis.yml Add python 3.9 to travis tests 4 weeks ago
HISTORY.md pre v0.1.1 1 week ago
LICENSE Add initial functional code, ported from Talos 2 years ago
README.md v0.0.23 3 weeks ago
dev-requirements.txt Bump discord-py from 1.7.1 to 1.7.2 1 week ago
setup.cfg Bump version: 0.1.0 → 0.1.1 1 week ago
setup.py pre v0.1.1 1 week ago
tasks.py Makefile file for 'invoke' tool (tasks.py) 2 weeks ago

README.md

dpytest

Build Status Documentation StatusDiscord Server

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.