-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
When the bot sends a message in response to dpytest.message, the message's author is the test user that was created in runner during configuration. As a result, one of the checks that occurs when the message is sent raises an AttributeError because it takes a user channel that tries to find the id of an auto-created user that does not exist in this guild channel:
@pytest.mark.asyncio
async def test_good_log_create():
test_user = dpytest.backend.make_user("Test1", 2, id_num=386420570449051649)
test_guild = dpytest.backend.make_guild(name="Test")
test_channel = dpytest.backend.make_text_channel(guild=test_guild, name="Test")
test_member = dpytest.backend.make_member(test_user, test_guild)
await dpytest.message("something that starts the execution of one of the discord.py functions containing send() in the body", channel=test_channel, member=test_user)
File "lib/python3.11/site-packages/discord/abc.py", line 718, in permissions_for
if self.guild.owner_id == obj.id:
^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'
Fix:
@pytest.mark.asyncio
async def test_good_log_create():
state_user = dpytest.backend.get_state().user
test_user = dpytest.backend.make_user("Test1", 2, id_num=386420570449051649)
test_guild = dpytest.backend.make_guild(name="Test")
test_channel = dpytest.backend.make_text_channel(guild=test_guild, name="Test")
test_member = dpytest.backend.make_member(test_user, test_guild)
test_member3 = dpytest.backend.make_member(state_user, test_guild)
await dpytest.message("...", channel=test_channel, member=test_user)
I propose to somehow fix this in the documentation. Or make a method that will set the author when sending a message from the tested bot.
Metadata
Metadata
Assignees
Labels
No labels