summaryrefslogtreecommitdiff
path: root/numpydoc/tests/test_numpydoc.py
diff options
context:
space:
mode:
authorEric Larson <larson.eric.d@gmail.com>2022-07-13 08:55:05 -0400
committerGitHub <noreply@github.com>2022-07-13 08:55:05 -0400
commitd9c8d6766a20500015f53ffc12fb6b552014912b (patch)
tree1e535781814ec9f40b7f3bb4d14ab8a1f1755dbe /numpydoc/tests/test_numpydoc.py
parentc796da669a9d3714126a3fde7221f9c47aef93c7 (diff)
downloadnumpydoc-d9c8d6766a20500015f53ffc12fb6b552014912b.tar.gz
ENH: Add support for dict show_inherited_class_members (#415)
* ENH: Add support for dict show_inherited_class_members * STY: Black * TST: Add test
Diffstat (limited to 'numpydoc/tests/test_numpydoc.py')
-rw-r--r--numpydoc/tests/test_numpydoc.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/numpydoc/tests/test_numpydoc.py b/numpydoc/tests/test_numpydoc.py
index 0c8b6d6..d414b1c 100644
--- a/numpydoc/tests/test_numpydoc.py
+++ b/numpydoc/tests/test_numpydoc.py
@@ -1,5 +1,7 @@
import pytest
+from collections import defaultdict
from io import StringIO
+from pathlib import PosixPath
from copy import deepcopy
from numpydoc.numpydoc import mangle_docstrings, _clean_text_signature, update_config
from numpydoc.xref import DEFAULT_LINKS
@@ -41,7 +43,7 @@ class MockApp:
self.warningiserror = False
-def test_mangle_docstrings():
+def test_mangle_docstrings_basic():
s = """
A top section before
@@ -69,6 +71,35 @@ A top section before
assert "upper" not in [x.strip() for x in lines]
+def test_mangle_docstrings_inherited_class_members():
+ # if subclass docs are rendered, this PosixPath should have Path.samefile
+ p = """
+A top section before
+
+.. autoclass:: pathlib.PosixPath
+"""
+ lines = p.split("\n")
+ app = MockApp()
+ mangle_docstrings(app, "class", "pathlib.PosixPath", PosixPath, {}, lines)
+ lines = [x.strip() for x in lines]
+ assert "samefile" in lines
+ app.config.numpydoc_show_inherited_class_members = False
+ lines = p.split("\n")
+ mangle_docstrings(app, "class", "pathlib.PosixPath", PosixPath, {}, lines)
+ lines = [x.strip() for x in lines]
+ assert "samefile" not in lines
+ app.config.numpydoc_show_inherited_class_members = dict()
+ lines = p.split("\n")
+ mangle_docstrings(app, "class", "pathlib.PosixPath", PosixPath, {}, lines)
+ lines = [x.strip() for x in lines]
+ assert "samefile" in lines
+ app.config.numpydoc_show_inherited_class_members = defaultdict(lambda: False)
+ lines = p.split("\n")
+ mangle_docstrings(app, "class", "pathlib.PosixPath", PosixPath, {}, lines)
+ lines = [x.strip() for x in lines]
+ assert "samefile" not in lines
+
+
def test_clean_text_signature():
assert _clean_text_signature(None) is None
assert _clean_text_signature("func($self)") == "func()"