Skip to content

Commit

Permalink
Doctests in ufuncs should respect __doctest_skip__
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Feb 15, 2022
1 parent c7b22b1 commit 253c5dd
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pytest_doctestplus/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,7 @@ def collect(self):
runner = doctest.DebugRunner(
verbose=False, optionflags=options, checker=OutputChecker())

tests = finder.find(module)
for method in module.__dict__.values():
if _is_numpy_ufunc(method):
found = finder.find(method, module=module)
tests += found

for test in tests:
for test in finder.find(module):
if test.examples: # skip empty doctests
ignore_warnings_context_needed = False
show_warnings_context_needed = False
Expand Down Expand Up @@ -664,13 +658,19 @@ def check_required_modules(cls, mods):

def find(self, obj, name=None, module=None, globs=None, extraglobs=None):
tests = doctest.DocTestFinder.find(self, obj, name, module, globs, extraglobs)

if name is None and hasattr(obj, '__name__'):
name = obj.__name__
else:
raise ValueError("DocTestFinder.find: name must be given "
"when obj.__name__ doesn't exist: {!r}"
.format((type(obj),)))

for ufunc_name, ufunc_method in obj.__dict__.items():
if _is_numpy_ufunc(ufunc_method):
tests += doctest.DocTestFinder.find(self, ufunc_method, f'{name}.{ufunc_name}')

if hasattr(obj, '__doctest_skip__') or hasattr(obj, '__doctest_requires__'):
if name is None and hasattr(obj, '__name__'):
name = obj.__name__
else:
raise ValueError("DocTestFinder.find: name must be given "
"when obj.__name__ doesn't exist: {!r}"
.format((type(obj),)))

def test_filter(test):
for pat in getattr(obj, '__doctest_skip__', []):
Expand Down

0 comments on commit 253c5dd

Please sign in to comment.