summaryrefslogtreecommitdiff
path: root/numpydoc/tests/test_docscrape.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpydoc/tests/test_docscrape.py')
-rw-r--r--numpydoc/tests/test_docscrape.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py
index 049d2a2..227f872 100644
--- a/numpydoc/tests/test_docscrape.py
+++ b/numpydoc/tests/test_docscrape.py
@@ -1,6 +1,7 @@
from collections import namedtuple
from copy import deepcopy
import re
+import sys
import textwrap
import warnings
@@ -1624,6 +1625,26 @@ def test__error_location_no_name_attr():
nds._error_location(msg=msg)
+@pytest.mark.skipif(
+ sys.version_info < (3, 8), reason="cached_property was added in 3.8"
+)
+def test_class_docstring_cached_property():
+ """Ensure that properties marked with the `cached_property` decorator
+ are listed in the Methods section. See gh-432."""
+ from functools import cached_property
+
+ class Foo:
+ _x = [1, 2, 3]
+
+ @cached_property
+ def val(self):
+ return self._x
+
+ class_docstring = get_doc_object(Foo)
+ assert len(class_docstring["Attributes"]) == 1
+ assert class_docstring["Attributes"][0].name == "val"
+
+
if __name__ == "__main__":
import pytest