77
88from .conftest import SphinxBuilder
99
10+ try :
11+ import myst_parser # noqa: F401
12+
13+ MYST_INSTALLED = True
14+ except ImportError :
15+ MYST_INSTALLED = False
16+
1017SNIPPETS_PATH = Path (__file__ ).parent .parent / "docs" / "snippets"
1118SNIPPETS_GLOB_RST = list ((SNIPPETS_PATH / "rst" ).glob ("[!_]*" ))
1219SNIPPETS_GLOB_MYST = list ((SNIPPETS_PATH / "myst" ).glob ("[!_]*" ))
@@ -29,7 +36,7 @@ def test_snippets_rst(
2936 sphinx_builder : Callable [..., SphinxBuilder ], path : Path , file_regression
3037):
3138 """Test snippets written in RestructuredText (before post-transforms)."""
32- builder = sphinx_builder ()
39+ builder = sphinx_builder (conf_kwargs = { "extensions" : [ "sphinx_design" ]} )
3340 content = "Heading\n -------" + "\n \n " + path .read_text (encoding = "utf8" )
3441 builder .src_path .joinpath ("index.rst" ).write_text (content , encoding = "utf8" )
3542 write_assets (builder .src_path )
@@ -49,6 +56,7 @@ def test_snippets_rst(
4956 SNIPPETS_GLOB_MYST ,
5057 ids = [path .name [: - len (path .suffix )] for path in SNIPPETS_GLOB_MYST ],
5158)
59+ @pytest .mark .skipif (not MYST_INSTALLED , reason = "myst-parser not installed" )
5260def test_snippets_myst (
5361 sphinx_builder : Callable [..., SphinxBuilder ], path : Path , file_regression
5462):
@@ -77,7 +85,7 @@ def test_snippets_rst_post(
7785 sphinx_builder : Callable [..., SphinxBuilder ], path : Path , file_regression
7886):
7987 """Test snippets written in RestructuredText (after HTML post-transforms)."""
80- builder = sphinx_builder ()
88+ builder = sphinx_builder (conf_kwargs = { "extensions" : [ "sphinx_design" ]} )
8189 content = "Heading\n -------" + "\n \n " + path .read_text (encoding = "utf8" )
8290 builder .src_path .joinpath ("index.rst" ).write_text (content , encoding = "utf8" )
8391 write_assets (builder .src_path )
@@ -97,6 +105,7 @@ def test_snippets_rst_post(
97105 SNIPPETS_GLOB_MYST ,
98106 ids = [path .name [: - len (path .suffix )] for path in SNIPPETS_GLOB_MYST ],
99107)
108+ @pytest .mark .skipif (not MYST_INSTALLED , reason = "myst-parser not installed" )
100109def test_snippets_myst_post (
101110 sphinx_builder : Callable [..., SphinxBuilder ], path : Path , file_regression
102111):
@@ -120,7 +129,7 @@ def test_sd_hide_title_rst(
120129 sphinx_builder : Callable [..., SphinxBuilder ], file_regression
121130):
122131 """Test that the root title is hidden."""
123- builder = sphinx_builder ()
132+ builder = sphinx_builder (conf_kwargs = { "extensions" : [ "sphinx_design" ]} )
124133 content = ":sd_hide_title:\n \n Heading\n -------\n \n content"
125134 builder .src_path .joinpath ("index.rst" ).write_text (content , encoding = "utf8" )
126135 builder .build ()
@@ -134,6 +143,7 @@ def test_sd_hide_title_rst(
134143 )
135144
136145
146+ @pytest .mark .skipif (not MYST_INSTALLED , reason = "myst-parser not installed" )
137147def test_sd_hide_title_myst (
138148 sphinx_builder : Callable [..., SphinxBuilder ], file_regression
139149):
@@ -152,6 +162,7 @@ def test_sd_hide_title_myst(
152162 )
153163
154164
165+ @pytest .mark .skipif (not MYST_INSTALLED , reason = "myst-parser not installed" )
155166def test_sd_custom_directives (
156167 sphinx_builder : Callable [..., SphinxBuilder ], file_regression
157168):
0 commit comments