CraftSpider / dpytest

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

Equal strings got assertion error #73

Closed LeCuay closed 1 year ago

LeCuay commented 2 years ago

Summary

So I have this very simple block of code:

@pytest.mark.asyncio
async def test_linkchannel_ko(bot):
    await dpytest.message(content=f'{bot.command_prefix}linkchannel')
    msg = dpytest.verify().message()
    expected_content = 'This command is not implemented yet.'

    assert msg.content(expected_content), f'\'{msg._content}\' != \'{expected_content}\''

And yet somehow I got this error message:

FAILED tests/bot/cogs/test_rol.py::test_linkchannel_ko - AssertionError: 'This command is not implemented yet.' != 'This command is not implemented yet.'

The part of code that I'm testing is as simple as this:

@commands.command()
async def linkchannel(self, ctx: commands.Context, name=''):
    """
    Links current channel to Campaign.
    This campaign can be passed as `name` or selected by reacting to the embed message.

    Parameters
    ----------
    name: Optional
        Name of the campaign.
        E.g. ..linkchannel "My Campaign"
    """

    await ctx.send('This command is not implemented yet.')

I genuinely do not understand.

Blotz commented 2 years ago

So i tried recreating this issue and it looks like this code is working. Maybe there is a typo or zero width unicode character. At least i can confirm that the code should work. Sorry i couldn't be more helpful ://