Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better AssertionError messages when using dpytest.verify() #115

Open
ctmbl opened this issue Jun 7, 2023 · 3 comments
Open

Add better AssertionError messages when using dpytest.verify() #115

ctmbl opened this issue Jun 7, 2023 · 3 comments

Comments

@ctmbl
Copy link
Contributor

ctmbl commented Jun 7, 2023

Is your feature request related to a problem? Please describe.

When writing my tests I need to debug why an AssertionError is raised when verifying a message. I can't know what message is being verified so I can't debug the bot/cog.

Describe the solution you'd like

A clear diff between the expected message content (passed as parameter) and the message sent by the bot, as pytest/python do:

>       assert ret_user.username == "dummy"
E       AssertionError: assert 'dumy' == 'dummy'
E         - dumy
E         + dummy
E         ?  +

tests/test_dummy_db_manager.py:17: AssertionError

Describe alternatives you've considered

Currently it looks like:

E       assert <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840>
E        +  where <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840> = <bound method VerifyMessage.content of <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840>>("isn't in the database")
E        +    where <bound method VerifyMessage.content of <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840>> = <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840>.content
E        +      where <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840> = <bound method VerifyMessage.contains of <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840>>()
E        +        where <bound method VerifyMessage.contains of <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840>> = <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840>.contains
E        +          where <discord.ext.test.verify.VerifyMessage object at 0x7fe857f5d840> = <bound method Verify.message of <discord.ext.test.verify.Verify object at 0x7fe857f5dd50>>()
E        +            where <bound method Verify.message of <discord.ext.test.verify.Verify object at 0x7fe857f5dd50>> = <discord.ext.test.verify.Verify object at 0x7fe857f5dd50>.message
E        +              where <discord.ext.test.verify.Verify object at 0x7fe857f5dd50> = <function verify at 0x7fe8582cab90>()
E        +                where <function verify at 0x7fe8582cab90> = dpytest.verify

Maybe at least writing a better __str__ or __repr__ for the Verify* classes could be a solution

@ctmbl ctmbl changed the title A Add better AssertionError messages when using dpytest.verify() Jun 7, 2023
@Sergeileduc
Copy link
Collaborator

are you serious ?

@ctmbl
Copy link
Contributor Author

ctmbl commented Jun 7, 2023

@Sergeileduc sorry the first title/issue body was just missclick 😓

@Sergeileduc
Copy link
Collaborator

ha ha, ok, no worries !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants