Skip to content

Commit 65a867c

Browse files
committed
refactor: Improve API tests robustness
1 parent 32fbf97 commit 65a867c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

project/tests/test_api.py.jinja

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from typing import TYPE_CHECKING
88

99
import griffe
1010
import pytest
11-
from mkdocstrings.inventory import Inventory
11+
from mkdocstrings import Inventory
1212

1313
import {{ python_package_import_name }}
1414

@@ -153,7 +153,11 @@ def test_inventory_matches_api(
153153
public_api_paths = {obj.path for obj in public_objects}
154154
public_api_paths.add("{{ python_package_import_name }}")
155155
for item in inventory.values():
156-
if item.domain == "py" and "(" not in item.name:
156+
if (
157+
item.domain == "py"
158+
and "(" not in item.name
159+
and (item.name == "{{ python_package_import_name }}" or item.name.startswith("{{ python_package_import_name }}."))
160+
):
157161
obj = loader.modules_collection[item.name]
158162
if obj.path not in public_api_paths and not any(path in public_api_paths for path in obj.aliases):
159163
not_in_api.append(item.name)

0 commit comments

Comments
 (0)