Closed Edward-Knight closed 3 years ago
There are changes in dpytest most recent versions that will break your existing tests. The issue you are having here is related to discord.py gateway intents though.
Since version 1.5 of discord.py they require intents
to be set for certain features. Some of dpytest also depends on intents being set or certain processing used by dpytest is ignored by discord.py. The ignored processing causes incomplete or missing objects - the error you have here.
Try to run these tests again but add the intents parameter to your commands.Bot
call. You will need to specify the members
intent even if your bot doesn't use it, and other intents may be required depending on your tests.
Check this documentation for more info about intents: https://discordpy.readthedocs.io/en/stable/intents.html
Thank you very much for your swift response!
I adjusted the test code to:
import discord.ext.test as dpytest
import pytest
from discord import Intents
from discord.ext import commands
@pytest.mark.asyncio
async def test_bot():
bot = commands.Bot("/", intents=Intents(members=True))
@bot.command()
async def ping(ctx):
await ctx.send("pong")
dpytest.configure(bot)
await dpytest.message("/ping")
assert dpytest.verify().message().content("pong")
And I now get the results:
=== Testing dpytest==0.5.0
Testing discord.py==1.7.3... Passed!
Testing discord.py==1.7.2... Passed!
Testing discord.py==1.7.1... Passed!
Testing discord.py==1.7.0... Passed!
Testing discord.py==1.6.0... Passed!
Testing discord.py==1.5.1... E AttributeError: 'ConnectionState' object has no attribute 'member_cache_flags'
Testing discord.py==1.5.0... E AttributeError: 'ConnectionState' object has no attribute 'member_cache_flags'
Hi, this is sort of a follow up from #39.
I can run
dpytest
0.0.22
, but upgrading to0.0.23
or later gives me variousAttributeError
s. I wasn't sure which versions ofdiscord.py
it's meant to be compatible with, so I wrote a script to test a bunch of them.testdpy.py
(same as #39):testdpy.sh
:And the results, from running on the
python:3.8
docker image:Expand
Any help would be greatly appreciated! 😊