Skip to content

Commit 3ab8843

Browse files
committed
Few test fixes
1 parent 82eff8b commit 3ab8843

File tree

2 files changed

+66
-11
lines changed

2 files changed

+66
-11
lines changed

autodocsumm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def add_content(self, *args, **kwargs):
303303

304304
self.add_autosummary()
305305

306-
if self.options.autosummary_no_nesting:
306+
if self.options.get("autosummary-no-nesting"):
307307
self.options["no-autosummary"] = "True"
308308

309309

tests/test_autodocsumm.py

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ 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)
5352
try:
5453
self.assertIn('Should be included', html)
5554
except AssertionError: # sphinx>=3.5
@@ -59,8 +58,15 @@ def test_module(self, app, status, warning):
5958
'<span class="pre">included\'</span>',
6059
html
6160
)
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)
6269

63-
self.assertNotIn('Should also be skipped', html)
6470
try:
6571
self.assertIn('Should also be included', html)
6672
except AssertionError: # sphinx>=3.5
@@ -71,6 +77,15 @@ def test_module(self, app, status, warning):
7177
'<span class="pre">included\'</span>',
7278
html
7379
)
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)
7489

7590
@with_app(buildername='html', srcdir=sphinx_supp,
7691
copy_srcdir_to_tmpdir=True)
@@ -86,8 +101,18 @@ def test_module_no_nesting(self, app, status, warning):
86101
self.assertIn('<span class="pre">small_data</span>', html)
87102

88103
# test that elements of TestClass are not autosummarized, since nesting is disabled.
89-
self.assertNotIn('<span class="pre">test_method</span>', html)
90-
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+
)
91116

92117
# test the members are still displayed
93118
self.assertIn('<dt id="dummy.Class_CallTest">', html)
@@ -123,12 +148,42 @@ def test_module_with_title(self, app, status, warning):
123148
# test whether the data is shown correctly
124149
self.assertIn('<span class="pre">large_data</span>', html)
125150
self.assertIn('<span class="pre">small_data</span>', html)
126-
127-
self.assertNotIn('Should be skipped', html)
128-
self.assertIn('Should be included', html)
129-
130-
self.assertNotIn('Should also be skipped', html)
131-
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)
132187

133188
@with_app(buildername='html', srcdir=sphinx_supp,
134189
copy_srcdir_to_tmpdir=True)

0 commit comments

Comments
 (0)