Skip to content

TST: Add inherited method #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpydoc/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def mangle_docstrings(app, what, name, obj, options, lines):
doc = get_doc_object(obj, what, u_NL.join(lines), config=cfg,
builder=app.builder)
lines[:] = str(doc).split(u_NL)
except:
except Exception:
logger.error('[numpydoc] While processing docstring for %r', name)
raise

Expand Down
12 changes: 10 additions & 2 deletions numpydoc/tests/test_full.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from distutils.version import LooseVersion
import os.path as op
import re
import shutil

import pytest
import sphinx
from sphinx.application import Sphinx
from sphinx.util.docutils import docutils_namespace

Expand All @@ -25,9 +27,12 @@ def ignore(src, names):
toctrees_dir = op.join(temp_dir, '_build', 'toctrees')
# Avoid warnings about re-registration, see:
# https://github.com/sphinx-doc/sphinx/issues/5038
kwargs = dict()
if LooseVersion(sphinx.__version__) >= LooseVersion('1.8'):
kwargs.update(warningiserror=True, keep_going=True)
with docutils_namespace():
app = Sphinx(src_dir, conf_dir, out_dir, toctrees_dir,
buildername='html')
buildername='html', **kwargs)
# need to build within the context manager
# for automodule and backrefs to work
app.build(False, [])
Expand All @@ -46,6 +51,9 @@ def test_MyClass(sphinx_app):
'numpydoc_test_module.MyClass.html')
with open(class_html, 'r') as fid:
html = fid.read()
# ensure that no autodoc weirdness ($) occurs
assert '$self' not in html
assert '__init__' in html # inherited
# escaped * chars should no longer be preceded by \'s,
# if we see a \* in the output we know it's incorrect:
assert r'\*' not in html
Expand Down Expand Up @@ -77,7 +85,7 @@ def test_reference(sphinx_app):
["generated", "numpydoc_test_module.MyClass.html"],
]

expected_lengths = [3, 1, 1]
expected_lengths = [1, 1, 1]

for html_file, expected_length in zip(html_files, expected_lengths):
html_file = op.join(out_dir, *html_file)
Expand Down
5 changes: 4 additions & 1 deletion numpydoc/tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,10 @@ def test_bad_generic_functions(self, capsys, func):
],
)
def test_bad_docstrings(self, capsys, klass, func, msgs):
result = validate_one(self._import_path(klass=klass, func=func))
with pytest.warns(None) as w:
result = validate_one(self._import_path(klass=klass, func=func))
if len(w):
assert all('Unknown section' in str(ww.message) for ww in w)
for msg in msgs:
assert msg in " ".join(err[1] for err in result["errors"])

Expand Down
2 changes: 1 addition & 1 deletion numpydoc/tests/tinybuild/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ clean:
rm -rf generated/

html:
sphinx-build -b html -d _build/doctrees . _build/html
sphinx-build -nWT --keep-going -b html -d _build/doctrees . _build/html

show:
@python -c "import webbrowser; webbrowser.open_new_tab('file://$(PWD)/_build/html/index.html')"
2 changes: 2 additions & 0 deletions numpydoc/tests/tinybuild/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
]
project = 'numpydoc_test_module'
autosummary_generate = True
autodoc_default_options = {'inherited-members': None}
source_suffix = '.rst'
master_doc = 'index'
exclude_patterns = ['_build']
Expand All @@ -19,4 +20,5 @@
}
nitpicky = True
highlight_language = 'python3'
numpydoc_class_members_toctree = False
numpydoc_xref_param_type = True
4 changes: 3 additions & 1 deletion numpydoc/tests/tinybuild/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ numpydoc_test_module
====================

.. automodule:: numpydoc_test_module
:members:
:no-members:
:no-inherited-members:
:no-special-members:
9 changes: 2 additions & 7 deletions numpydoc/tests/tinybuild/numpydoc_test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
References
----------
.. [1] https://numpydoc.readthedocs.io

"""

__all__ = ['MyClass', 'my_function']
Expand All @@ -36,12 +35,8 @@ class MyClass(object):
.. [2] https://numpydoc.readthedocs.io
"""

def __init__(self, *args, **kwargs):
pass

def example(self):
"""Exampel function
"""
def example(self, x):
"""Example method."""
pass


Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
addopts =
--showlocals --doctest-modules -ra --cov-report= --cov=numpydoc
--junit-xml=junit-results.xml --ignore=doc/conf.py
junit_family = xunit2
filterwarnings =
ignore:'U' mode is deprecated:DeprecationWarning
ignore:.*sphinx\.util\.smartypants is deprecated.*:
ignore:Using or importing the ABCs.*:DeprecationWarning