-
Notifications
You must be signed in to change notification settings - Fork 451
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
Avoid modifying global category/filters in tests #6503
Conversation
8a574e1
to
2681bcb
Compare
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.
Looks good! It is better to have tests isolated by avoiding of global variables.
I think the actual reason for the error in #6500 was this line:
async def test_get_my_channel_tags_xxx(metadata_store, tags_db, mock_dlmgr_get_download, my_channel, rest_api): # pylint: disable=redefined-outer-name
"""
Test whether XXX tags are correctly filtered
"""
with db_session:
...
default_xxx_filter.xxx_terms = {"wrongterm"}
If it was executed before tests in test_category.py
it could destroy the expected default_xxx_filter
content.
I think it should be fixed as well (in this or separate PR)
src/tribler-core/tribler_core/components/metadata_store/category_filter/tests/test_category.py
Outdated
Show resolved
Hide resolved
2681bcb
to
89caada
Compare
Kudos, SonarCloud Quality Gate passed! |
@kozlovsky thanks for pointing that out! I tried to see if there is an easy way to get rid of the We could consider making a component out of the category filter and pass it to the components that need it (e.g., REST endpoints/metadata store). I'm not sure how much work that is but this is more something for a subsequent PR. |
In the metadata store tests, we are modifying
default_xxx_filter
and add a term to it. This change is persistent across different tests, potentially leading to test failures. This PR modifies the tests and increases flexibility by creating separate instances ofCategory
andXXXFilter
. These objects are manipulated without affectingdefault_category_filter
ordefault_xxx_filter
.Fixes #6500 (hopefully)