@@ -49,11 +49,43 @@ def test_module(self, app, status, warning):
4949 self .assertIn ('<span class="pre">large_data</span>' , html )
5050 self .assertIn ('<span class="pre">small_data</span>' , html )
5151
52- self .assertNotIn ('Should be skipped' , html )
53- self .assertIn ('Should be included' , html )
54-
55- self .assertNotIn ('Should also be skipped' , html )
56- self .assertIn ('Should also be included' , html )
52+ try :
53+ self .assertIn ('Should be included' , html )
54+ except AssertionError : # sphinx>=3.5
55+ self .assertIn (
56+ '<span class="pre">\' Should</span> '
57+ '<span class="pre">be</span> '
58+ '<span class="pre">included\' </span>' ,
59+ html
60+ )
61+ self .assertNotIn (
62+ '<span class="pre">\' Should</span> '
63+ '<span class="pre">be</span> '
64+ '<span class="pre">skipped\' </span>' ,
65+ html
66+ )
67+ else :
68+ self .assertNotIn ('Should be skipped' , html )
69+
70+ try :
71+ self .assertIn ('Should also be included' , html )
72+ except AssertionError : # sphinx>=3.5
73+ self .assertIn (
74+ '<span class="pre">\' Should</span> '
75+ '<span class="pre">also</span> '
76+ '<span class="pre">be</span> '
77+ '<span class="pre">included\' </span>' ,
78+ html
79+ )
80+ self .assertNotIn (
81+ '<span class="pre">\' Should</span> '
82+ '<span class="pre">also</span> '
83+ '<span class="pre">be</span> '
84+ '<span class="pre">skipped\' </span>' ,
85+ html
86+ )
87+ else :
88+ self .assertNotIn ('Should also be skipped' , html )
5789
5890 @with_app (buildername = 'html' , srcdir = sphinx_supp ,
5991 copy_srcdir_to_tmpdir = True )
@@ -69,8 +101,18 @@ def test_module_no_nesting(self, app, status, warning):
69101 self .assertIn ('<span class="pre">small_data</span>' , html )
70102
71103 # test that elements of TestClass are not autosummarized, since nesting is disabled.
72- self .assertNotIn ('<span class="pre">test_method</span>' , html )
73- self .assertNotIn ('<span class="pre">test_attr</span>' , html )
104+ try :
105+ self .assertNotIn ('<span class="pre">test_method</span>' , html )
106+ self .assertNotIn ('<span class="pre">test_attr</span>' , html )
107+ except AssertionError : # sphinx>=3.5
108+ self .assertEqual (
109+ len (re .findall ('<span class="pre">test_method</span>' , html )),
110+ 1 ,
111+ )
112+ self .assertEqual (
113+ len (re .findall ('<span class="pre">test_attr</span>' , html )),
114+ 1 ,
115+ )
74116
75117 # test the members are still displayed
76118 self .assertIn ('<dt id="dummy.Class_CallTest">' , html )
@@ -106,12 +148,42 @@ def test_module_with_title(self, app, status, warning):
106148 # test whether the data is shown correctly
107149 self .assertIn ('<span class="pre">large_data</span>' , html )
108150 self .assertIn ('<span class="pre">small_data</span>' , html )
109-
110- self .assertNotIn ('Should be skipped' , html )
111- self .assertIn ('Should be included' , html )
112-
113- self .assertNotIn ('Should also be skipped' , html )
114- self .assertIn ('Should also be included' , html )
151+ try :
152+ self .assertIn ('Should be included' , html )
153+ except AssertionError : # sphinx>=3.5
154+ self .assertIn (
155+ '<span class="pre">\' Should</span> '
156+ '<span class="pre">be</span> '
157+ '<span class="pre">included\' </span>' ,
158+ html
159+ )
160+ self .assertNotIn (
161+ '<span class="pre">\' Should</span> '
162+ '<span class="pre">be</span> '
163+ '<span class="pre">skipped\' </span>' ,
164+ html
165+ )
166+ else :
167+ self .assertNotIn ('Should be skipped' , html )
168+ try :
169+ self .assertIn ('Should also be included' , html )
170+ except AssertionError : # sphinx>=3.5
171+ self .assertIn (
172+ '<span class="pre">\' Should</span> '
173+ '<span class="pre">also</span> '
174+ '<span class="pre">be</span> '
175+ '<span class="pre">included\' </span>' ,
176+ html
177+ )
178+ self .assertNotIn (
179+ '<span class="pre">\' Should</span> '
180+ '<span class="pre">also</span> '
181+ '<span class="pre">be</span> '
182+ '<span class="pre">skipped\' </span>' ,
183+ html
184+ )
185+ else :
186+ self .assertNotIn ('Should also be skipped' , html )
115187
116188 @with_app (buildername = 'html' , srcdir = sphinx_supp ,
117189 copy_srcdir_to_tmpdir = True )
@@ -146,7 +218,15 @@ def test_class(self, app, status, warning):
146218 self .assertIn ('<span class="pre">small_data</span>' , html )
147219
148220 self .assertNotIn ('Should be skipped' , html )
149- self .assertIn ('Should be included' , html )
221+ try :
222+ self .assertIn ('Should be included' , html )
223+ except AssertionError : # sphinx>=3.5
224+ self .assertIn (
225+ '<span class="pre">\' Should</span> '
226+ '<span class="pre">be</span> '
227+ '<span class="pre">included\' </span>' ,
228+ html
229+ )
150230
151231 self .assertIn ('DummySection' , html )
152232 self .assertTrue (in_between (
0 commit comments