7
7
8
8
from .conftest import SphinxBuilder
9
9
10
+ try :
11
+ import myst_parser # noqa: F401
12
+
13
+ MYST_INSTALLED = True
14
+ except ImportError :
15
+ MYST_INSTALLED = False
16
+
10
17
SNIPPETS_PATH = Path (__file__ ).parent .parent / "docs" / "snippets"
11
18
SNIPPETS_GLOB_RST = list ((SNIPPETS_PATH / "rst" ).glob ("[!_]*" ))
12
19
SNIPPETS_GLOB_MYST = list ((SNIPPETS_PATH / "myst" ).glob ("[!_]*" ))
@@ -29,7 +36,7 @@ def test_snippets_rst(
29
36
sphinx_builder : Callable [..., SphinxBuilder ], path : Path , file_regression
30
37
):
31
38
"""Test snippets written in RestructuredText (before post-transforms)."""
32
- builder = sphinx_builder ()
39
+ builder = sphinx_builder (conf_kwargs = { "extensions" : [ "sphinx_design" ]} )
33
40
content = "Heading\n -------" + "\n \n " + path .read_text (encoding = "utf8" )
34
41
builder .src_path .joinpath ("index.rst" ).write_text (content , encoding = "utf8" )
35
42
write_assets (builder .src_path )
@@ -49,6 +56,7 @@ def test_snippets_rst(
49
56
SNIPPETS_GLOB_MYST ,
50
57
ids = [path .name [: - len (path .suffix )] for path in SNIPPETS_GLOB_MYST ],
51
58
)
59
+ @pytest .mark .skipif (not MYST_INSTALLED , reason = "myst-parser not installed" )
52
60
def test_snippets_myst (
53
61
sphinx_builder : Callable [..., SphinxBuilder ], path : Path , file_regression
54
62
):
@@ -77,7 +85,7 @@ def test_snippets_rst_post(
77
85
sphinx_builder : Callable [..., SphinxBuilder ], path : Path , file_regression
78
86
):
79
87
"""Test snippets written in RestructuredText (after HTML post-transforms)."""
80
- builder = sphinx_builder ()
88
+ builder = sphinx_builder (conf_kwargs = { "extensions" : [ "sphinx_design" ]} )
81
89
content = "Heading\n -------" + "\n \n " + path .read_text (encoding = "utf8" )
82
90
builder .src_path .joinpath ("index.rst" ).write_text (content , encoding = "utf8" )
83
91
write_assets (builder .src_path )
@@ -97,6 +105,7 @@ def test_snippets_rst_post(
97
105
SNIPPETS_GLOB_MYST ,
98
106
ids = [path .name [: - len (path .suffix )] for path in SNIPPETS_GLOB_MYST ],
99
107
)
108
+ @pytest .mark .skipif (not MYST_INSTALLED , reason = "myst-parser not installed" )
100
109
def test_snippets_myst_post (
101
110
sphinx_builder : Callable [..., SphinxBuilder ], path : Path , file_regression
102
111
):
@@ -120,7 +129,7 @@ def test_sd_hide_title_rst(
120
129
sphinx_builder : Callable [..., SphinxBuilder ], file_regression
121
130
):
122
131
"""Test that the root title is hidden."""
123
- builder = sphinx_builder ()
132
+ builder = sphinx_builder (conf_kwargs = { "extensions" : [ "sphinx_design" ]} )
124
133
content = ":sd_hide_title:\n \n Heading\n -------\n \n content"
125
134
builder .src_path .joinpath ("index.rst" ).write_text (content , encoding = "utf8" )
126
135
builder .build ()
@@ -134,6 +143,7 @@ def test_sd_hide_title_rst(
134
143
)
135
144
136
145
146
+ @pytest .mark .skipif (not MYST_INSTALLED , reason = "myst-parser not installed" )
137
147
def test_sd_hide_title_myst (
138
148
sphinx_builder : Callable [..., SphinxBuilder ], file_regression
139
149
):
@@ -152,6 +162,7 @@ def test_sd_hide_title_myst(
152
162
)
153
163
154
164
165
+ @pytest .mark .skipif (not MYST_INSTALLED , reason = "myst-parser not installed" )
155
166
def test_sd_custom_directives (
156
167
sphinx_builder : Callable [..., SphinxBuilder ], file_regression
157
168
):
0 commit comments