-
Notifications
You must be signed in to change notification settings - Fork 263
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
Spruce up deterministic_cache #1195
Conversation
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.
axelrod/deterministic_cache.py
Outdated
cache[key2] = result2 | ||
... | ||
if some_key in cache: | ||
do_something(cache[some_key] |
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: missing )
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.
Done.
axelrod/deterministic_cache.py
Outdated
"""Validate a deterministic cache player key. | ||
|
||
The key should always be a 3-tuple, with a pair of axelrod.Player | ||
instnaces and one integer. Both players should be deterministic. |
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: instances
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.
Done.
@@ -27,6 +28,9 @@ def tearDownClass(cls): | |||
os.remove(cls.test_save_file) | |||
os.remove(cls.test_load_file) | |||
|
|||
def setUp(self): | |||
self.cache = DeterministicCache() |
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.
Does this create a shared cache across all tests? That could cause some confusion.
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.
I see that the tests all appear logically correct in that self.cache
is only used for expected invalid keys, however I think I'd prefer that they each instantiate a new one.
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.
That's a good point. But since setUp
is called before every test method, self.cache
is assigned a new, empty cache for each one. Was that your concern?
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.
Yep, thanks for the explanation.
* Improve docstrings and add module docstring * Move key helper functions to module level * Refactored unit tests to test public API
Next bit for #347.
This includes several things:
@staticmethod
IMO is best used sparingly.