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

Can cache properties with mangled names #167

Closed
wants to merge 1 commit into from

Conversation

AWhetter
Copy link

@AWhetter AWhetter commented Jul 2, 2019

Fixes #102

self.__doc__ = getattr(func, "__doc__")
self.func = func
def __init__(self, func, name=None):
if not callable(func):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if this was the right thing to do here. I did consider making func optional so that users have to specify arguments with keywords. Ultimately I decided to go with the pattern that already existed in the other classes.

@@ -77,31 +122,39 @@ def test_cached_property(self):
self.assert_control(check, 2)

# The cached version demonstrates how nothing is added after the first
self.assert_cached(check, 1)
self.assert_cached(check, 1)
for cached_attr, total_attr in self.cached_attrs:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unsure if this was the right thing to do as well. It makes the tests a bit more complicated. I considered making a separate TestCase classes for each type of attribute, but considering that the duplicate tests would be testing pretty much the same thing, it made sense to me to test all types of attribute in a single test.

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

Successfully merging this pull request may close these issues.

cached_property decorator doesn't work with mangled method names
1 participant