Skip to content

Commit f65d35f

Browse files
author
Chris Rossi
authored
fix: Fix repr() for ComputedProperty (#291)
Fixes #256
1 parent 891e94d commit f65d35f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/google-cloud-ndb/google/cloud/ndb/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4267,6 +4267,7 @@ class ComputedProperty(GenericProperty):
42674267
"""
42684268

42694269
_kwargs = None
4270+
_func = None
42704271

42714272
def __init__(
42724273
self, func, name=None, indexed=None, repeated=None, verbose_name=None

packages/google-cloud-ndb/tests/unit/test_model.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3723,6 +3723,19 @@ def lower_name(self):
37233723
prop = model.ComputedProperty(lower_name)
37243724
assert prop._func == lower_name
37253725

3726+
@staticmethod
3727+
def test_repr():
3728+
"""Regression test for #256
3729+
3730+
https://github.com/googleapis/python-ndb/issues/256
3731+
"""
3732+
3733+
def lower_name(self):
3734+
return self.lower() # pragma: NO COVER
3735+
3736+
prop = model.ComputedProperty(lower_name)
3737+
assert "lower_name" in repr(prop)
3738+
37263739
@staticmethod
37273740
def test__set_value():
37283741
prop = model.ComputedProperty(lambda self: self) # pragma: NO COVER

0 commit comments

Comments
 (0)