Coverage for tests/test_themes.py: 100.00%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-09 18:38 +0100

1"""Tests for the different themes we claim to support.""" 

2 

3from __future__ import annotations 

4 

5from typing import TYPE_CHECKING 

6 

7import pytest 

8 

9if TYPE_CHECKING: 

10 from mkdocstrings import MkdocstringsPlugin 

11 

12 

13@pytest.mark.parametrize( 

14 "plugin", 

15 [ 

16 {"theme": "mkdocs"}, 

17 {"theme": "readthedocs"}, 

18 {"theme": {"name": "material"}}, 

19 ], 

20 indirect=["plugin"], 

21) 

22@pytest.mark.parametrize( 

23 "module", 

24 [ 

25 "mkdocstrings.extension", 

26 "mkdocstrings.inventory", 

27 "mkdocstrings.loggers", 

28 "mkdocstrings.handlers.base", 

29 "mkdocstrings.handlers.rendering", 

30 "mkdocstrings_handlers.python.handler", 

31 "mkdocstrings_handlers.python.rendering", 

32 ], 

33) 

34def test_render_themes_templates(module: str, plugin: MkdocstringsPlugin) -> None: 

35 """Test rendering of a given theme's templates. 

36 

37 Parameters: 

38 module: The module to load and render (parametrized). 

39 plugin: The plugin instance (parametrized fixture). 

40 """ 

41 handler = plugin.handlers.get_handler("python") 

42 handler._update_env(plugin.md, config=plugin.handlers._tool_config) # type: ignore[attr-defined] 

43 options = handler.get_options({}) 

44 data = handler.collect(module, options) 

45 handler.render(data, options)