11import unittest
22from sphinx_runpython .ext_test_case import ExtTestCase , ignore_warnings
3+ from sphinx_runpython .epkg .sphinx_epkg_extension import (
4+ epkg_role ,
5+ epkg_node ,
6+ visit_epkg_node ,
7+ depart_epkg_node ,
8+ )
39from pyquickhelper .helpgen import rst2html
410
11+ tives = [("epkg" , epkg_role , epkg_node , visit_epkg_node , depart_epkg_node )]
12+
513
614class TestEpkgExtension (ExtTestCase ):
715 @ignore_warnings (PendingDeprecationWarning )
@@ -20,7 +28,7 @@ def test_epkg_module(self):
2028 content ,
2129 writer = "custom" ,
2230 keep_warnings = True ,
23- directives = None ,
31+ directives = tives ,
2432 layout = "sphinx" ,
2533 epkg_dictionary = {
2634 "pandas" : (
@@ -35,15 +43,15 @@ def test_epkg_module(self):
3543
3644 t1 = "abeforea"
3745 if t1 not in html :
38- raise Exception (html )
46+ raise AssertionError (html )
3947
4048 t1 = "aftera"
4149 if t1 not in html :
42- raise Exception (html )
50+ raise AssertionError (html )
4351
4452 t1 = "http://pandas.pydata.org/pandas-docs/stable/generated/"
4553 if t1 not in html :
46- raise Exception (html )
54+ raise AssertionError (html )
4755
4856 @ignore_warnings (PendingDeprecationWarning )
4957 def test_epkg_module_twice (self ):
@@ -63,7 +71,7 @@ def test_epkg_module_twice(self):
6371 content ,
6472 writer = "custom" ,
6573 keep_warnings = True ,
66- directives = None ,
74+ directives = tives ,
6775 layout = "sphinx" ,
6876 epkg_dictionary = {
6977 "pandas" : "http://pandas.pydata.org/pandas-docs/stable/generated/" ,
@@ -89,7 +97,7 @@ def test_epkg_sub(self):
8997 content ,
9098 writer = "custom" ,
9199 keep_warnings = True ,
92- directives = None ,
100+ directives = tives ,
93101 layout = "sphinx" ,
94102 epkg_dictionary = {
95103 "pandas" : (
@@ -105,25 +113,25 @@ def test_epkg_sub(self):
105113
106114 t1 = "abeforea"
107115 if t1 not in html :
108- raise Exception (html )
116+ raise AssertionError (html )
109117
110118 t1 = "aftera"
111119 if t1 not in html :
112- raise Exception (html )
120+ raise AssertionError (html )
113121
114122 spl = html .split ("abeforea" )[- 1 ].split ("aftera" )[0 ]
115123
116124 t1 = "`"
117125 if t1 in html :
118- raise Exception (f"\n **{ spl } **\n ----\n { html } " )
126+ raise AssertionError (f"\n **{ spl } **\n ----\n { html } " )
119127
120128 t1 = 'href="http://www.7-zip.org/"'
121129 if t1 not in html :
122- raise Exception (html )
130+ raise AssertionError (html )
123131
124132 t1 = 'href="http://pandas.pydata.org/pandas-docs/stable/generated/DataFrame.to_html.html"'
125133 if t1 not in html :
126- raise Exception (html )
134+ raise AssertionError (html )
127135
128136 @ignore_warnings (PendingDeprecationWarning )
129137 def test_epkg_function (self ):
@@ -146,7 +154,7 @@ def pandas_link(input):
146154 content ,
147155 writer = "custom" ,
148156 keep_warnings = True ,
149- directives = None ,
157+ directives = tives ,
150158 layout = "sphinx" ,
151159 epkg_dictionary = {
152160 "pandas" : (
@@ -163,25 +171,25 @@ def pandas_link(input):
163171
164172 t1 = "abeforea"
165173 if t1 not in html :
166- raise Exception (html )
174+ raise AssertionError (html )
167175
168176 t1 = "aftera"
169177 if t1 not in html :
170- raise Exception (html )
178+ raise AssertionError (html )
171179
172180 spl = html .split ("abeforea" )[- 1 ].split ("aftera" )[0 ]
173181
174182 t1 = "`"
175183 if t1 in html :
176- raise Exception (f"\n **{ spl } **\n ----\n { html } " )
184+ raise AssertionError (f"\n **{ spl } **\n ----\n { html } " )
177185
178186 t1 = 'href="http://www.7-zip.org/"'
179187 if t1 not in html :
180- raise Exception (html )
188+ raise AssertionError (html )
181189
182190 t1 = 'href="pandas|DataFrame|to_html"'
183191 if t1 not in html :
184- raise Exception (html )
192+ raise AssertionError (html )
185193
186194 @ignore_warnings (PendingDeprecationWarning )
187195 def test_epkg_class (self ):
@@ -205,7 +213,7 @@ def __call__(self, input):
205213 content ,
206214 writer = "custom" ,
207215 keep_warnings = True ,
208- directives = None ,
216+ directives = tives ,
209217 layout = "sphinx" ,
210218 epkg_dictionary = {
211219 "pandas" : (
@@ -222,25 +230,25 @@ def __call__(self, input):
222230
223231 t1 = "abeforea"
224232 if t1 not in html :
225- raise Exception (html )
233+ raise AssertionError (html )
226234
227235 t1 = "aftera"
228236 if t1 not in html :
229- raise Exception (html )
237+ raise AssertionError (html )
230238
231239 spl = html .split ("abeforea" )[- 1 ].split ("aftera" )[0 ]
232240
233241 t1 = "`"
234242 if t1 in html :
235- raise Exception (f"\n **{ spl } **\n ----\n { html } " )
243+ raise AssertionError (f"\n **{ spl } **\n ----\n { html } " )
236244
237245 t1 = 'href="http://www.7-zip.org/"'
238246 if t1 not in html :
239- raise Exception (html )
247+ raise AssertionError (html )
240248
241249 t1 = 'href="pandas|DataFrame|to_html"'
242250 if t1 not in html :
243- raise Exception (html )
251+ raise AssertionError (html )
244252
245253 @ignore_warnings (PendingDeprecationWarning )
246254 def test_epkg_function_string (self ):
@@ -260,7 +268,7 @@ def test_epkg_function_string(self):
260268 content ,
261269 writer = "custom" ,
262270 keep_warnings = True ,
263- directives = None ,
271+ directives = tives ,
264272 layout = "sphinx" ,
265273 epkg_dictionary = {
266274 "pandas" : (
@@ -280,25 +288,25 @@ def test_epkg_function_string(self):
280288
281289 t1 = "abeforea"
282290 if t1 not in html :
283- raise Exception (html )
291+ raise AssertionError (html )
284292
285293 t1 = "aftera"
286294 if t1 not in html :
287- raise Exception (html )
295+ raise AssertionError (html )
288296
289297 spl = html .split ("abeforea" )[- 1 ].split ("aftera" )[0 ]
290298
291299 t1 = "`"
292300 if t1 in html :
293- raise Exception (f"\n **{ spl } **\n ----\n { html } " )
301+ raise AssertionError (f"\n **{ spl } **\n ----\n { html } " )
294302
295303 t1 = 'href="http://www.7-zip.org/"'
296304 if t1 not in html :
297- raise Exception (html )
305+ raise AssertionError (html )
298306
299307 t1 = 'href="pandas|DataFrame|to_html"'
300308 if t1 not in html :
301- raise Exception (html )
309+ raise AssertionError (html )
302310
303311 @ignore_warnings (PendingDeprecationWarning )
304312 def test_epkg_function_long_link (self ):
@@ -317,17 +325,17 @@ def test_epkg_function_long_link(self):
317325 content ,
318326 writer = "custom" ,
319327 keep_warnings = True ,
320- directives = None ,
328+ directives = tives ,
321329 layout = "sphinx" ,
322330 )
323331
324332 t1 = 'href="http://first.part/secondpart"'
325333 if t1 not in html :
326- raise Exception (html )
334+ raise AssertionError (html )
327335
328336 t1 = ">one link on two lines</a>"
329337 if t1 not in html :
330- raise Exception (html )
338+ raise AssertionError (html )
331339
332340
333341if __name__ == "__main__" :
0 commit comments