Skip to content

Commit

Permalink
fixed bug in docstring test
Browse files Browse the repository at this point in the history
  • Loading branch information
pauladkisson committed Sep 5, 2023
1 parent 78562a0 commit 89b146e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

def traverse_class(cls, objs):
"""Traverse a class and its methods and append them to objs."""
for name, obj in inspect.getmembers(cls, inspect.isfunction or inspect.ismethod):
predicate = lambda x: inspect.isfunction(x) or inspect.ismethod(x)
for name, obj in inspect.getmembers(cls, predicate=predicate):
objs.append(obj)


def traverse_module(module, objs):
"""Traverse all classes and functions in a module and append them to objs."""
objs.append(module)
for name, obj in inspect.getmembers(module, inspect.isclass or inspect.isfunction or inspect.ismethod):
predicate = lambda x: inspect.isclass(x) or inspect.isfunction(x) or inspect.ismethod(x)
for name, obj in inspect.getmembers(module, predicate=predicate):
parent_package = obj.__module__.split(".")[0]
if parent_package != "roiextractors": # avoid traversing external dependencies
continue
Expand All @@ -39,7 +41,6 @@ def traverse_package(package, objs):

objs = []
traverse_package(roiextractors, objs)
print(objs)


@pytest.mark.parametrize("obj", objs)
Expand Down

0 comments on commit 89b146e

Please sign in to comment.