Skip to content

Commit 99cb0f3

Browse files
add test
1 parent 5773b71 commit 99cb0f3

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

numpydoc/tests/test_docscrape.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ParseError
1616
)
1717
from numpydoc.docscrape_sphinx import (SphinxDocString, SphinxClassDoc,
18-
SphinxFunctionDoc)
18+
SphinxFunctionDoc, get_doc_object)
1919
from nose.tools import (assert_equal, assert_raises, assert_list_equal,
2020
assert_true)
2121

@@ -1199,6 +1199,33 @@ def test_templated_sections():
11991199
""")
12001200

12011201

1202+
def test_nonstandard_property():
1203+
# test discovery of a property that does not satisfy isinstace(.., property)
1204+
1205+
class SpecialProperty(object):
1206+
1207+
def __init__(self, axis=0, doc=""):
1208+
self.axis = axis
1209+
self.__doc__ = doc
1210+
1211+
def __get__(self, obj, type):
1212+
if obj is None:
1213+
# Only instances have actual _data, not classes
1214+
return self
1215+
else:
1216+
return obj._data.axes[self.axis]
1217+
1218+
def __set__(self, obj, value):
1219+
obj._set_axis(self.axis, value)
1220+
1221+
class Dummy:
1222+
1223+
attr = SpecialProperty(doc="test attribute")
1224+
1225+
doc = get_doc_object(Dummy)
1226+
assert "test attribute" in str(doc)
1227+
1228+
12021229
if __name__ == "__main__":
12031230
import nose
12041231
nose.run()

0 commit comments

Comments
 (0)