1
+ from distutils .version import LooseVersion
1
2
import os .path as op
2
3
import re
3
4
import shutil
4
5
5
6
import pytest
7
+ import sphinx
6
8
from sphinx .application import Sphinx
7
9
from sphinx .util .docutils import docutils_namespace
8
10
@@ -25,9 +27,12 @@ def ignore(src, names):
25
27
toctrees_dir = op .join (temp_dir , '_build' , 'toctrees' )
26
28
# Avoid warnings about re-registration, see:
27
29
# https://github.com/sphinx-doc/sphinx/issues/5038
30
+ kwargs = dict ()
31
+ if LooseVersion (sphinx .__version__ ) >= LooseVersion ('1.8' ):
32
+ kwargs .update (warningiserror = True , keep_going = True )
28
33
with docutils_namespace ():
29
34
app = Sphinx (src_dir , conf_dir , out_dir , toctrees_dir ,
30
- buildername = 'html' )
35
+ buildername = 'html' , ** kwargs )
31
36
# need to build within the context manager
32
37
# for automodule and backrefs to work
33
38
app .build (False , [])
@@ -46,6 +51,9 @@ def test_MyClass(sphinx_app):
46
51
'numpydoc_test_module.MyClass.html' )
47
52
with open (class_html , 'r' ) as fid :
48
53
html = fid .read ()
54
+ # ensure that no autodoc weirdness ($) occurs
55
+ assert '$self' not in html
56
+ assert '__init__' in html # inherited
49
57
# escaped * chars should no longer be preceded by \'s,
50
58
# if we see a \* in the output we know it's incorrect:
51
59
assert r'\*' not in html
@@ -77,7 +85,7 @@ def test_reference(sphinx_app):
77
85
["generated" , "numpydoc_test_module.MyClass.html" ],
78
86
]
79
87
80
- expected_lengths = [3 , 1 , 1 ]
88
+ expected_lengths = [1 , 1 , 1 ]
81
89
82
90
for html_file , expected_length in zip (html_files , expected_lengths ):
83
91
html_file = op .join (out_dir , * html_file )
0 commit comments