CraftSpider / dpytest

A package that assists in writing tests for discord.py
MIT License
103 stars 24 forks source link

'create_text_channel' ignores 'overwrites' argument #63

Open coolwind0202 opened 3 years ago

coolwind0202 commented 3 years ago

I wrote a test using create_text_channel() function.

I passed overwrites argument to the function.

Then I realized the overwrites was not be reflected.

I executed following code:

@pytest.mark.asyncio
async def test(bot: discord.Client):
    test_guild: discord.Guild = bot.guilds[0]
    role: discord.Role = await test_guild.create_role(name='Role new', mentionable=True)

    perm = discord.PermissionOverwrite(read_messages=True)
    channel: discord.TextChannel = await test_guild.create_text_channel(name='New Channel', overwrites={ role: perm })
    result: discord.PermissionOverwrite = channel.overwrites[role]

    assert perm == result

Test session info:

================================== FAILURES ===================================
____________________________________ test _____________________________________

bot = <discord.client.Client object at 0x000001FC78E89670>

    @pytest.mark.asyncio
    async def test(bot: discord.Client):
        test_guild: discord.Guild = bot.guilds[0]
        role: discord.Role = await test_guild.create_role(name='Role new', mentionable=True)

        perm = discord.PermissionOverwrite(read_messages=True)
        channel: discord.TextChannel = await test_guild.create_text_channel(name='New Channel', overwrites={ role: perm })
        result: discord.PermissionOverwrite = channel.overwrites[role]

>       assert perm == result
E       assert <discord.perm...001FC78E7C910> == <discord.perm...001FC78E7CA60>
E         Use -v to get the full diff

tests\test_channel\test_text_channel.py:40: AssertionError