File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 11from collections import namedtuple
22from copy import deepcopy
33import re
4+ import sys
45import textwrap
56import warnings
67
@@ -1624,6 +1625,26 @@ def __call__(self):
16241625 nds ._error_location (msg = msg )
16251626
16261627
1628+ @pytest .mark .skipif (
1629+ sys .version_info < (3 , 8 ), reason = "cached_property was added in 3.8"
1630+ )
1631+ def test_class_docstring_cached_property ():
1632+ """Ensure that properties marked with the `cached_property` decorator
1633+ are listed in the Methods section. See gh-432."""
1634+ from functools import cached_property
1635+
1636+ class Foo :
1637+ _x = [1 , 2 , 3 ]
1638+
1639+ @cached_property
1640+ def val (self ):
1641+ return self ._x
1642+
1643+ class_docstring = get_doc_object (Foo )
1644+ assert len (class_docstring ["Attributes" ]) == 1
1645+ assert class_docstring ["Attributes" ][0 ].name == "val"
1646+
1647+
16271648if __name__ == "__main__" :
16281649 import pytest
16291650
You can’t perform that action at this time.
0 commit comments