@@ -19,13 +19,21 @@ def in_between(full, sub, s0, *others):
1919 return full .index (sub ) > i0 and full .index (sub ) < last
2020
2121
22+ def get_html (app , fname ):
23+ try :
24+ return (app .outdir / fname ).read_text ()
25+ except TypeError :
26+ with open (app .outdir + '/' + fname ) as f :
27+ return f .read ()
28+
29+
2230class TestAutosummaryDocumenter (unittest .TestCase ):
2331
2432 @with_app (buildername = 'html' , srcdir = sphinx_supp ,
2533 copy_srcdir_to_tmpdir = True )
2634 def test_module (self , app , status , warning ):
2735 app .build ()
28- html = (app . outdir / 'test_module.html' ). read_text ( )
36+ html = get_html (app , 'test_module.html' )
2937 self .assertIn ('<span class="pre">TestClass</span>' , html )
3038 self .assertIn ('<span class="pre">test_func</span>' , html )
3139 self .assertIn ('<span class="pre">test_method</span>' , html )
@@ -49,7 +57,7 @@ def test_module(self, app, status, warning):
4957 copy_srcdir_to_tmpdir = True )
5058 def test_module_with_title (self , app , status , warning ):
5159 app .build ()
52- html = (app . outdir / 'test_module_title.html' ). read_text ( )
60+ html = get_html (app , 'test_module_title.html' )
5361 self .assertIn ('<span class="pre">TestClass</span>' , html )
5462 self .assertIn ('<span class="pre">test_func</span>' , html )
5563 self .assertIn ('<span class="pre">test_method</span>' , html )
@@ -73,7 +81,7 @@ def test_module_with_title(self, app, status, warning):
7381 copy_srcdir_to_tmpdir = True )
7482 def test_class (self , app , status , warning ):
7583 app .build ()
76- html = (app . outdir / ' test_class.html'). read_text ( )
84+ html = get_html (app , '/ test_class.html' )
7785 self .assertIn ('<span class="pre">test_method</span>' , html )
7886 self .assertIn ('<span class="pre">test_attr</span>' , html )
7987
0 commit comments