-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Refactoring to replace unittests with pytests #2610
Conversation
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2610-all-demos |
@abidlabs I noticed on Friday that pytest emits some warnings along the lines of “coroutine test_….. was never awaited”. Which means those tests are never really checked 😬 Confusingly, these tests have “@pytest.mark.asyncio”. I wonder if this PR will get rid of those will get rid of those warnings. |
Exactly @freddyaboulton it seems that some async tests are not running at all! l elaborate in a follow up message |
I've updated the original message with more details, and this is now ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix @abidlabs ! I think the fact some components now raise ValueError about invalid type
parameter values is worthy of a mention in the changelog though.
test/test_components.py
Outdated
@@ -1,14 +1,20 @@ | |||
""" | |||
Tests for all of the componets defined on components.lpy. They are divided into two types of tests: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit typo: components.lpy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks
That's fair, thanks @freddyaboulton for the review! Will add a changelog and merge in to avoid conflicts |
I started going through our tests and converting them from unittest to pytest, when I noticed something wrong -- some of our tests were passing even though they should not have been. It seems that pytest was letting async tests automatically pass if they were written as part of a unittest class.
For example, if you change the
TestBlocksMethods::test_dict_inputs_in_config
test intest_blocks.py
to anything else, you'll find that it still passes:This is not the case if we change the tests to be pure pytests. So I went through and converted all of our tests to pytest. I noticed some other tests that should not have been passing, either due to the tests being incorrect or there being bugs in our codebase. Nothing too major, but here are the changes I made:
test_components.py
passed in a list toInterface.__call__
instead of the input parameters as separate arguments. This is not correct and the tests have been fixed.test_components.py
, several tests used.serialize()
in a way that is not supported or used in our library anymore. They've been rewritten or removed.ValueError()
when passed an invalid argument fortype
. They now correctly do this.All of the above issues are now fixed in the library, and all of our tests have been converted to pytest format.
Closes: #1784