diff options
author | David Baumgold <david@davidbaumgold.com> | 2016-02-18 11:17:21 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-02-18 16:42:35 -0500 |
commit | 51491f6c8f37c5257c7a3eff350a860482295876 (patch) | |
tree | f797301c6bec83747290db646d2aef423e36ac0e | |
parent | 713e884bbf32a5f85d790de7a99cfcbfdde877d7 (diff) | |
download | sqlalchemy-51491f6c8f37c5257c7a3eff350a860482295876.tar.gz |
Failing test for documenting @hybrid_property with .expression
-rw-r--r-- | test/ext/test_hybrid.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ext/test_hybrid.py b/test/ext/test_hybrid.py index 744789c3c..09c3788a6 100644 --- a/test/ext/test_hybrid.py +++ b/test/ext/test_hybrid.py @@ -99,10 +99,12 @@ class PropertyExpressionTest(fixtures.TestBase, AssertsCompiledSQL): @hybrid.hybrid_property def value(self): + "This is an instance-level docstring" return int(self._value) - 5 @value.expression def value(cls): + "This is a class-level docstring" return func.foo(cls._value) + cls.bar_value @value.setter @@ -205,6 +207,17 @@ class PropertyExpressionTest(fixtures.TestBase, AssertsCompiledSQL): "FROM a AS a_1 WHERE foo(a_1.value) + bar(a_1.value) = :param_1" ) + def test_docstring(self): + A = self._fixture() + # This is tricky. `A.value` returns a SQL element, which has its + # own docstring, so it's reasonable to expect this to fail: + eq_(A.value.__doc__, "This is a class-level docstring") + # We can get at the hybrid_property object by going through the `__dict__` + # property, but even doing that, we end up with the wrong docstring! + # We should get the class-level docstring... + eq_(A.__dict__['value'].__doc__, "This is a class-level docstring") + # ... but we get the instance-level docstring, instead! + class PropertyValueTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def _fixture(self, assignable): |