-
Notifications
You must be signed in to change notification settings - Fork 157
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
Fix for config not updated in cases where it was already created #383
Conversation
Codecov Report
@@ Coverage Diff @@
## master #383 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 9 9
Lines 853 855 +2
Branches 89 90 +1
=====================================
+ Hits 853 855 +2
Continue to review full report at Codecov.
|
tests/ut/test_factory.py
Outdated
@@ -212,6 +212,18 @@ def test_set_empty_config(self): | |||
with pytest.raises(ValueError): | |||
caches.set_config({}) | |||
|
|||
def test_set_config_updates_default(self): |
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.
Hmmm I think I prefer a more explicit test. Something that checks that after doing a set_config
the caches that were in the config don't exist anymore
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.
Updated!
@@ -140,6 +140,8 @@ def set_config(self, config): | |||
""" | |||
if "default" not in config: | |||
raise ValueError("default config must be provided") | |||
for config_name in config.keys(): | |||
self._caches.pop(config_name, None) |
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.
Let's update the docstring with this new behavior, it may have some undesired side effects users should be aware. For example if you call multiple times set_config
you will be losing the reference to your caches, so we should at least explain it :)
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.
Added a new test. I'm accessing the private variable _caches
though, didn't know how to test it without it.
No description provided.