Skip to content

Commit 7abf268

Browse files
committed
tests: Support testing under mkdocstrings 1.0
Issue-10: #10
1 parent 4c3290d commit 7abf268

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

config/pytest.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ filterwarnings =
1414
error::EncodingWarning:mkdocstrings_handlers
1515
# TODO: remove once pytest-xdist 4 is released
1616
ignore:.*rsyncdir:DeprecationWarning:xdist
17+
ignore:.*`mdx` argument:DeprecationWarning:mkdocstrings
18+
ignore:.*`mdx_config` argument:DeprecationWarning:mkdocstrings
19+
# Ignore unraisable exception warnings from unclosed files and subprocesses
20+
ignore::pytest.PytestUnraisableExceptionWarning

src/mkdocstrings_handlers/python/handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class PythonHandler(BaseHandler):
4646
fallback_config: ClassVar[dict] = {"docstring_style": "markdown", "filters": ["!.*"]}
4747
"""The configuration used when falling back to re-collecting an object to get its anchor.
4848
49-
This configuration is used in [`Handlers.get_anchors`][mkdocstrings.Handlers.get_anchors].
50-
5149
When trying to fix (optional) cross-references, the autorefs plugin will try to collect
5250
an object with every configured handler until one succeeds. It will then try to get
5351
an anchor for it. It's because objects can have multiple identifiers (aliases),
@@ -185,6 +183,8 @@ def __init__(self, config: dict[str, Any], base_dir: Path, **kwargs: Any) -> Non
185183
stdin=PIPE,
186184
bufsize=-1,
187185
env=env,
186+
encoding="utf-8",
187+
text=True,
188188
)
189189

190190
def get_inventory_urls(self) -> list[tuple[str, dict[str, Any]]]:
@@ -312,7 +312,7 @@ def teardown(self) -> None:
312312
logger.debug("Tearing process down")
313313
self.process.terminate()
314314

315-
def render(self, data: CollectorItem, options: MutableMapping[str, Any]) -> str:
315+
def render(self, data: CollectorItem, options: MutableMapping[str, Any]) -> str: # type: ignore[override]
316316
"""Render the collected data into HTML."""
317317
template = self.env.get_template(f"{data['category']}.html")
318318

tests/test_collector.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ def test_collect_result_error(retval: dict, exp_res: str) -> None:
3030
with mock.patch("mkdocstrings_handlers.python.handler.json.loads") as m_loads: # noqa: SIM117
3131
with pytest.raises(CollectionError) as excinfo: # noqa: PT012
3232
m_loads.return_value = retval
33-
handler = get_handler({}, _FakeMkDocsConfig, theme="material") # type: ignore[arg-type]
33+
handler = get_handler(
34+
{},
35+
_FakeMkDocsConfig, # type: ignore[arg-type]
36+
theme="material",
37+
custom_templates=None,
38+
mdx=None,
39+
mdx_config=None,
40+
)
3441
assert handler.collect("", {})
3542
assert str(excinfo.value) == exp_res

tests/test_themes.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
@pytest.mark.parametrize(
2323
"module",
2424
[
25-
"mkdocstrings.extension",
26-
"mkdocstrings.inventory",
27-
"mkdocstrings.loggers",
28-
"mkdocstrings.handlers.base",
29-
"mkdocstrings.handlers.rendering",
3025
"mkdocstrings_handlers.python.handler",
3126
"mkdocstrings_handlers.python.rendering",
3227
],

0 commit comments

Comments
 (0)