Skip to content

Commit 21a7ed2

Browse files
committed
tests: Fix API tests
1 parent 6812234 commit 21a7ed2

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/test_api.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytest
1111
from mkdocstrings.inventory import Inventory
1212

13-
import mkdocstrings_handlers
13+
from mkdocstrings_handlers import python
1414

1515
if TYPE_CHECKING:
1616
from collections.abc import Iterator
@@ -19,19 +19,19 @@
1919
@pytest.fixture(name="loader", scope="module")
2020
def _fixture_loader() -> griffe.GriffeLoader:
2121
loader = griffe.GriffeLoader()
22-
loader.load("mkdocstrings_handlers")
22+
loader.load("mkdocstrings_handlers.python")
2323
loader.resolve_aliases()
2424
return loader
2525

2626

2727
@pytest.fixture(name="internal_api", scope="module")
2828
def _fixture_internal_api(loader: griffe.GriffeLoader) -> griffe.Module:
29-
return loader.modules_collection["mkdocstrings_handlers._internal"]
29+
return loader.modules_collection["mkdocstrings_handlers.python._internal"]
3030

3131

3232
@pytest.fixture(name="public_api", scope="module")
3333
def _fixture_public_api(loader: griffe.GriffeLoader) -> griffe.Module:
34-
return loader.modules_collection["mkdocstrings_handlers"]
34+
return loader.modules_collection["mkdocstrings_handlers.python"]
3535

3636

3737
def _yield_public_objects(
@@ -50,7 +50,7 @@ def _yield_public_objects(
5050
if modules:
5151
yield member
5252
yield from _yield_public_objects(
53-
member, # type: ignore[arg-type]
53+
member,
5454
modules=modules,
5555
modulelevel=modulelevel,
5656
inherited=inherited,
@@ -62,7 +62,7 @@ def _yield_public_objects(
6262
continue
6363
if member.is_class and not modulelevel:
6464
yield from _yield_public_objects(
65-
member, # type: ignore[arg-type]
65+
member,
6666
modules=modules,
6767
modulelevel=False,
6868
inherited=inherited,
@@ -97,11 +97,11 @@ def _fixture_inventory() -> Inventory:
9797

9898

9999
def test_exposed_objects(modulelevel_internal_objects: list[griffe.Object | griffe.Alias]) -> None:
100-
"""All public objects in the internal API are exposed under `mkdocstrings_handlers`."""
100+
"""All public objects in the internal API are exposed under `mkdocstrings_handlers.python`."""
101101
not_exposed = [
102102
obj.path
103103
for obj in modulelevel_internal_objects
104-
if obj.name not in mkdocstrings_handlers.__all__ or not hasattr(mkdocstrings_handlers, obj.name)
104+
if obj.name not in python.__all__ or not hasattr(python, obj.name)
105105
]
106106
assert not not_exposed, "Objects not exposed:\n" + "\n".join(sorted(not_exposed))
107107

@@ -122,7 +122,7 @@ def _public_path(obj: griffe.Object | griffe.Alias) -> bool:
122122
return obj.is_public and (obj.parent is None or _public_path(obj.parent))
123123

124124
multiple_locations = {}
125-
for obj_name in mkdocstrings_handlers.__all__:
125+
for obj_name in python.__all__:
126126
obj = public_api[obj_name]
127127
if obj.aliases and (
128128
public_aliases := [path for path, alias in obj.aliases.items() if path != obj.path and _public_path(alias)]
@@ -152,6 +152,7 @@ def test_inventory_matches_api(
152152
not_in_api = []
153153
public_api_paths = {obj.path for obj in public_objects}
154154
public_api_paths.add("mkdocstrings_handlers")
155+
public_api_paths.add("mkdocstrings_handlers.python")
155156
for item in inventory.values():
156157
if item.domain == "py" and "(" not in item.name:
157158
obj = loader.modules_collection[item.name]

0 commit comments

Comments
 (0)