dpytest
dpytest copied to clipboard
Guild.unban(User) Not Implimented
File "~/Coding/Linux/python/discord/cogs/admin.py", line 77, in admin_unban
await context.guild.unban(user)
File "~/.local/lib/python3.12/site-packages/discord/guild.py", line 3979, in unban
await self._state.http.unban(user.id, self.id, reason=reason)
File "~/.local/lib/python3.12/site-packages/discord/ext/test/backend.py", line 89, in request
raise NotImplementedError(
NotImplementedError: Operation occured that isn't captured by the tests framework. This is dpytest's fault, please reportan issue on github. Debug Info: DELETE https://discord.com/api/v10/guilds/2/bans/2 with {'reason': None}
Problem:
Guild.unban(User) is not mocked by dpytest
Temp solution:
from unittest.mock import AsyncMock
guild.unban = AsyncMock()
How to recreate:
import discord.ext.test as dpytest
user = dpytest.backend.make_user("tester")
dpytest.backend.make_guild(name="test").unban(user)
This library is largely in maintenance mode. I would be willing to attempt to review and merge a PR adding this functionality.
same for me. I'm not currently actively developping for the project, but I can merge a PR, if you propose one.